Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document QueryError #486

Open
wants to merge 1 commit into
base: v2-unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package mgo

import "fmt"

func ExampleQueryError() {
e := &QueryError{
Code: 17406,
Message: "getMore executor error: CappedPositionLost: CollectionScan died due to failure to restore tailable cursor position. Last seen record id: RecordId(200138)",
Assertion: false,
}
fmt.Println(e.String())
// Output:
// getMore executor error: CappedPositionLost: CollectionScan died due to failure to restore tailable cursor position. Last seen record id: RecordId(200138)
}
3 changes: 3 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2397,7 +2397,10 @@ type queryError struct {
AssertionCode int "assertionCode"
}

// QueryError indicates an error that occurred during a Mongo query.
type QueryError struct {
// A list of codes can be found here:
// https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err
Code int
Message string
Assertion bool
Expand Down