-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.go
More file actions
49 lines (40 loc) · 1.39 KB
/
errors.go
File metadata and controls
49 lines (40 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package gomongo
import "fmt"
// ParseError represents a syntax error during parsing.
type ParseError struct {
Line int
Column int
Message string
Found string
Expected string
}
func (e *ParseError) Error() string {
if e.Found != "" && e.Expected != "" {
return fmt.Sprintf("parse error at line %d, column %d: found %q, expected %s", e.Line, e.Column, e.Found, e.Expected)
}
return fmt.Sprintf("parse error at line %d, column %d: %s", e.Line, e.Column, e.Message)
}
// UnsupportedOperationError represents an unsupported operation.
// This is returned for operations that are not planned for implementation.
type UnsupportedOperationError struct {
Operation string
}
func (e *UnsupportedOperationError) Error() string {
return fmt.Sprintf("unsupported operation: %s", e.Operation)
}
// PlannedOperationError represents an operation that is planned but not yet implemented.
// When the caller receives this error, it should fallback to mongosh.
type PlannedOperationError struct {
Operation string
}
func (e *PlannedOperationError) Error() string {
return fmt.Sprintf("operation %s is not yet implemented", e.Operation)
}
// UnsupportedOptionError represents an unsupported option in a supported method.
type UnsupportedOptionError struct {
Method string
Option string
}
func (e *UnsupportedOptionError) Error() string {
return fmt.Sprintf("unsupported option '%s' in %s", e.Option, e.Method)
}