Documentation
¶
Overview ¶
Package commonerrors providers errors shared by all handlers.
Index ¶
- Constants
- func CheckError(err error) error
- func NewCommandError(code ErrorCode, err error) error
- func NewCommandErrorMsg(code ErrorCode, msg string) error
- func NewCommandErrorMsgWithArgument(code ErrorCode, msg string, argument string) error
- func NewWriteErrorMsg(code ErrorCode, msg string) error
- type CommandError
- type ErrInfo
- type ErrorCode
- type ProtoErr
- type WriteErrors
- func (we *WriteErrors) Append(err error, index int32)
- func (we *WriteErrors) Code() ErrorCode
- func (we *WriteErrors) Document() *types.Document
- func (we *WriteErrors) Error() string
- func (we *WriteErrors) Info() *ErrInfo
- func (we *WriteErrors) Len() int
- func (we *WriteErrors) Merge(we2 *WriteErrors, index int32)
- func (we *WriteErrors) Unwrap() error
Constants ¶
const ( // ErrBadValue indicates wrong input. ErrBadValue = ErrorCode(2) // BadValue // ErrFailedToParse indicates user input parsing failure. ErrFailedToParse = ErrorCode(9) // FailedToParse // ErrTypeMismatch for $sort indicates that the expression in the $sort is not an object. ErrTypeMismatch = ErrorCode(14) // TypeMismatch // ErrNamespaceNotFound indicates that a collection is not found. ErrNamespaceNotFound = ErrorCode(26) // NamespaceNotFound // ErrUnsuitableValueType indicates that field could not be created for given value. ErrUnsuitableValueType = ErrorCode(28) // UnsuitableValueType // ErrConflictingUpdateOperators indicates that $set, $inc or $setOnInsert were used together. ErrConflictingUpdateOperators = ErrorCode(40) // ConflictingUpdateOperators // ErrCursorNotFound indicates that cursor is not found. ErrCursorNotFound = ErrorCode(43) // CursorNotFound // ErrNamespaceExists indicates that the collection already exists. ErrNamespaceExists = ErrorCode(48) // NamespaceExists // ErrInvalidID indicates that _id field is invalid. ErrInvalidID = ErrorCode(53) // InvalidID // ErrEmptyName indicates that the field name is empty. ErrEmptyName = ErrorCode(56) // EmptyName // ErrCommandNotFound indicates unknown command input. ErrCommandNotFound = ErrorCode(59) // CommandNotFound // ErrInvalidNamespace indicates that the collection name is invalid. ErrInvalidNamespace = ErrorCode(73) // InvalidNamespace // ErrOperationFailed indicates that the operation failed. ErrOperationFailed = ErrorCode(96) // OperationFailed // ErrDocumentValidationFailure indicates that document validation failed. ErrDocumentValidationFailure = ErrorCode(121) // DocumentValidationFailure // ErrNotImplemented indicates that a flag or command is not implemented. ErrNotImplemented = ErrorCode(238) // NotImplemented ErrMechanismUnavailable = ErrorCode(334) // MechanismUnavailable // ErrDuplicateKey indicates duplicate key violation. ErrDuplicateKey = ErrorCode(11000) // Location11000 // ErrStageGroupInvalidFields indicates group's fields must be an object. ErrStageGroupInvalidFields = ErrorCode(15947) // Location15947 // ErrStageGroupID indicates _id for a group can only be specified once. ErrStageGroupID = ErrorCode(15948) // Location15948 // ErrStageGroupMissingID indicates that group is missing an _id. ErrStageGroupMissingID = ErrorCode(15955) // Location15955 // ErrMatchBadExpression indicates match filter is not object. ErrMatchBadExpression = ErrorCode(15959) // Location15959 // ErrSortBadExpression indicates sort expression is not object. ErrSortBadExpression = ErrorCode(15973) // Location15973 // ErrSortBadValue indicates bad value in sort input. ErrSortBadValue = ErrorCode(15974) // Location15974 // ErrSortBadOrder indicates bad sort order input. ErrSortBadOrder = ErrorCode(15975) // Location15975 // ErrSortMissingKey indicates sort stage is missing sort key. ErrSortMissingKey = ErrorCode(15976) // Location15976 // ErrPathContainsEmptyElement indicates that the path contains an empty element. ErrPathContainsEmptyElement = ErrorCode(15998) // Location15998 // ErrGroupInvalidFieldPath indicates invalid path is given for group _id. ErrGroupInvalidFieldPath = ErrorCode(16872) // Location16872 // ErrInvalidArg indicates invalid argument in projection document. ErrInvalidArg = ErrorCode(28667) // Location28667 // ErrSliceFirstArg for $slice indicates that the first argument is not an array. ErrSliceFirstArg = ErrorCode(28724) // Location28724 // ErrProjectionInEx for $elemMatch indicates that inclusion statement found // while projection document already marked as exclusion. ErrProjectionInEx = ErrorCode(31253) // Location31253 // ErrProjectionExIn for $elemMatch indicates that exclusion statement found // while projection document already marked as inclusion. ErrProjectionExIn = ErrorCode(31254) // Location31254 // ErrStageCountNonString indicates that $count aggregation stage expected string. ErrStageCountNonString = ErrorCode(40156) // Location40156 // ErrStageCountNonEmptyString indicates that $count aggregation stage expected non-empty string. ErrStageCountNonEmptyString = ErrorCode(40157) // Location40157 // ErrStageCountBadPrefix indicates that $count stage cannot have invalid prefix. ErrStageCountBadPrefix = ErrorCode(40158) // Location40158 // ErrStageCountBadValue indicates that $count stage contains invalid value. ErrStageCountBadValue = ErrorCode(40160) // Location40160 // ErrStageGroupMultipleAccumulator indicates that group field must specify one accumulator. ErrStageGroupMultipleAccumulator = ErrorCode(40238) // Location40238 // ErrStageInvalid indicates invalid aggregation pipeline stage. ErrStageInvalid = ErrorCode(40323) // Location40323 // ErrStageGroupInvalidAccumulator indicates invalid accumulator field. ErrStageGroupInvalidAccumulator = ErrorCode(40234) // Location40234 // ErrEmptyFieldPath indicates that the field path is empty. ErrEmptyFieldPath = ErrorCode(40352) // Location40352 // ErrMissingField indicates that the required field in document is missing. ErrMissingField = ErrorCode(40414) // Location40414 // ErrFailedToParseInput indicates invalid input (absent or malformed fields). ErrFailedToParseInput = ErrorCode(40415) // Location40415 // ErrFreeMonitoringDisabled indicates that free monitoring is disabled // by command-line or config file. ErrFreeMonitoringDisabled = ErrorCode(50840) // Location50840 // ErrValueNegative indicates that value must not be negative. ErrValueNegative = ErrorCode(51024) // Location51024 // ErrRegexOptions indicates regex options error. ErrRegexOptions = ErrorCode(51075) // Location51075 // ErrRegexMissingParen indicates missing parentheses in regex expression. ErrRegexMissingParen = ErrorCode(51091) // Location51091 // ErrBadRegexOption indicates bad regex option value passed. ErrBadRegexOption = ErrorCode(51108) // Location51108 // ErrDuplicateField indicates duplicate field is specified. ErrDuplicateField = ErrorCode(4822819) // Location4822819 )
Variables ¶
This section is empty.
Functions ¶
func CheckError ¶
CheckError checks error type and returns properly translated error.
func NewCommandError ¶
NewCommandError creates a new wire protocol error.
Code shouldn't be zero, err can't be nil.
func NewCommandErrorMsg ¶
NewCommandErrorMsg is variant for NewCommandError with error string.
Code shouldn't be zero, err can't be empty.
func NewCommandErrorMsgWithArgument ¶
NewCommandErrorMsgWithArgument creates a new wire protocol error with an argument that caused the error.
func NewWriteErrorMsg ¶
NewWriteErrorMsg creates a new protocol write error with given ErrorCode and message.
Types ¶
type CommandError ¶
type CommandError struct {
// contains filtered or unexported fields
}
CommandError represents wire protocol command error.
func (*CommandError) Code ¶
func (e *CommandError) Code() ErrorCode
Code implements ProtoErr interface.
func (*CommandError) Document ¶
func (e *CommandError) Document() *types.Document
Document implements ProtoErr interface.
func (*CommandError) Error ¶
func (e *CommandError) Error() string
Error implements error interface.
func (*CommandError) Info ¶
func (e *CommandError) Info() *ErrInfo
Info implements ProtoErr interface.
func (*CommandError) Unwrap ¶
func (e *CommandError) Unwrap() error
Unwrap implements ProtoErr interface.
type ErrInfo ¶
type ErrInfo struct {
Argument string // command's argument, operator, or aggregation pipeline stage that caused an error
}
ErrInfo represents additional optional error information.
type ProtoErr ¶
type ProtoErr interface {
error
// Unwrap returns unwrapped error.
Unwrap() error
// Code returns ErrorCode.
Code() ErrorCode
// Document returns *types.Document.
Document() *types.Document
// Info returns *ErrInfo.
Info() *ErrInfo
}
ProtoErr represents protocol error type.
func ProtocolError ¶
ProtocolError converts any error to wire protocol error.
Nil panics, *CommandError or *WriteErrors (possibly wrapped) is returned unwrapped with true, any other value is wrapped with InternalError and returned with false.
type WriteErrors ¶
type WriteErrors struct {
// contains filtered or unexported fields
}
WriteErrors represents a slice of protocol write errors. It could be returned for Update, Insert, Delete, and Replace operations.
func (*WriteErrors) Append ¶
func (we *WriteErrors) Append(err error, index int32)
Append converts the err to the writeError type and appends it to WriteErrors. The index value is an index of the query with error.
func (*WriteErrors) Code ¶
func (we *WriteErrors) Code() ErrorCode
Code implements ProtoErr interface.
func (*WriteErrors) Document ¶
func (we *WriteErrors) Document() *types.Document
Document implements ProtoErr interface.
func (*WriteErrors) Info ¶
func (we *WriteErrors) Info() *ErrInfo
Info implements ProtoErr interface.
func (*WriteErrors) Merge ¶
func (we *WriteErrors) Merge(we2 *WriteErrors, index int32)
Merge merges the given WriteErrors with the current one and sets the given index.
func (*WriteErrors) Unwrap ¶
func (we *WriteErrors) Unwrap() error
Unwrap implements ProtoErr interface.