repogen/internal/mongo/errors.go

32 lines
773 B
Go
Raw Normal View History

2021-01-26 13:23:52 +00:00
package mongo
2021-02-14 04:48:09 +00:00
import (
"fmt"
)
2021-01-26 13:23:52 +00:00
2021-02-14 04:48:09 +00:00
// NewOperationNotSupportedError creates operationNotSupportedError
func NewOperationNotSupportedError(operationName string) error {
return operationNotSupportedError{OperationName: operationName}
2021-01-26 13:23:52 +00:00
}
2021-02-14 04:48:09 +00:00
type operationNotSupportedError struct {
OperationName string
}
func (err operationNotSupportedError) Error() string {
return fmt.Sprintf("operation '%s' not supported", err.OperationName)
}
// NewBsonTagNotFoundError creates bsonTagNotFoundError
func NewBsonTagNotFoundError(fieldName string) error {
return bsonTagNotFoundError{FieldName: fieldName}
}
type bsonTagNotFoundError struct {
FieldName string
}
func (err bsonTagNotFoundError) Error() string {
return fmt.Sprintf("bson tag of field '%s' not found", err.FieldName)
}