2020-11-04 14:42:20 -05:00
|
|
|
package errors
|
|
|
|
|
|
2020-11-17 18:54:23 -08:00
|
|
|
// Errors returned from this package may be tested against these errors with errors.Is.
|
|
|
|
|
// TODO: Deprecate sentinel errors in favor of the new Err type that includes unique ErrorId and Code.
|
2020-11-04 14:42:20 -05:00
|
|
|
var (
|
|
|
|
|
// ErrInvalidPublicId indicates an invalid PublicId.
|
2020-11-17 18:54:23 -08:00
|
|
|
ErrInvalidPublicId = New(InvalidParameter, "", WithMsg("invalid publicId"))
|
2020-11-04 14:42:20 -05:00
|
|
|
|
|
|
|
|
// ErrInvalidParameter is returned by create and update methods if
|
|
|
|
|
// an attribute on a struct contains illegal or invalid values.
|
2020-11-17 18:54:23 -08:00
|
|
|
ErrInvalidParameter = New(InvalidParameter, "", WithMsg("invalid parameter"))
|
2020-11-04 14:42:20 -05:00
|
|
|
|
|
|
|
|
// ErrInvalidFieldMask is returned by update methods if the field mask
|
|
|
|
|
// contains unknown fields or fields that cannot be updated.
|
2020-11-17 18:54:23 -08:00
|
|
|
ErrInvalidFieldMask = New(InvalidParameter, "", WithMsg("invalid field mask"))
|
2020-11-04 14:42:20 -05:00
|
|
|
|
|
|
|
|
// ErrEmptyFieldMask is returned by update methods if the field mask is
|
|
|
|
|
// empty.
|
2020-11-17 18:54:23 -08:00
|
|
|
ErrEmptyFieldMask = New(InvalidParameter, "", WithMsg("empty field mask"))
|
2020-11-04 14:42:20 -05:00
|
|
|
|
|
|
|
|
// ErrNotUnique is returned by create and update methods when a write
|
|
|
|
|
// to the repository resulted in a unique constraint violation.
|
2020-11-17 18:54:23 -08:00
|
|
|
ErrNotUnique = New(NotUnique, "", WithMsg("unique constraint violation"))
|
2020-11-04 14:42:20 -05:00
|
|
|
|
|
|
|
|
// ErrNotNull is returned by methods when a write to the repository resulted
|
|
|
|
|
// in a check constraint violation
|
2020-11-17 18:54:23 -08:00
|
|
|
ErrCheckConstraint = New(CheckConstraint, "", WithMsg("check constraint violated"))
|
2020-11-04 14:42:20 -05:00
|
|
|
|
|
|
|
|
// ErrNotNull is returned by methods when a write to the repository resulted
|
|
|
|
|
// in a not null constraint violation
|
2020-11-17 18:54:23 -08:00
|
|
|
ErrNotNull = New(NotNull, "", WithMsg("not null constraint violated"))
|
2020-11-04 14:42:20 -05:00
|
|
|
|
|
|
|
|
// ErrRecordNotFound returns a "record not found" error and it only occurs
|
|
|
|
|
// when attempting to read from the database into struct.
|
|
|
|
|
// When reading into a slice it won't return this error.
|
2020-11-17 18:54:23 -08:00
|
|
|
ErrRecordNotFound = New(RecordNotFound, "", WithMsg("record not found"))
|
2020-11-04 14:42:20 -05:00
|
|
|
|
|
|
|
|
// ErrMultipleRecords is returned by update and delete methods when a
|
|
|
|
|
// write to the repository would result in more than one record being
|
|
|
|
|
// changed resulting in the transaction being rolled back.
|
2020-11-17 18:54:23 -08:00
|
|
|
ErrMultipleRecords = New(MultipleRecords, "", WithMsg("multiple records"))
|
2020-11-04 14:42:20 -05:00
|
|
|
)
|