2020-11-04 14:42:20 -05:00
|
|
|
package errors
|
|
|
|
|
|
2020-12-09 10:11:38 -08:00
|
|
|
// Info contains details of the specific error code
|
2020-11-04 14:42:20 -05:00
|
|
|
type Info struct {
|
2020-12-09 10:11:38 -08:00
|
|
|
// Kind specifies the kind of error (unknown, parameter, integrity, etc).
|
|
|
|
|
Kind Kind
|
|
|
|
|
|
|
|
|
|
// Message provides a default message for the error code
|
2020-11-04 14:42:20 -05:00
|
|
|
Message string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// errorCodeInfo provides a map of unique Codes (IDs) to their
|
|
|
|
|
// corresponding Kind and a default Message.
|
|
|
|
|
var errorCodeInfo = map[Code]Info{
|
|
|
|
|
Unknown: {
|
|
|
|
|
Message: "unknown",
|
|
|
|
|
Kind: Other,
|
|
|
|
|
},
|
|
|
|
|
InvalidParameter: {
|
|
|
|
|
Message: "invalid parameter",
|
|
|
|
|
Kind: Parameter,
|
|
|
|
|
},
|
2020-12-09 10:11:38 -08:00
|
|
|
InvalidAddress: {
|
|
|
|
|
Message: "invalid address",
|
|
|
|
|
Kind: Parameter,
|
|
|
|
|
},
|
|
|
|
|
InvalidPublicId: {
|
|
|
|
|
Message: "invalid public id",
|
|
|
|
|
Kind: Parameter,
|
|
|
|
|
},
|
|
|
|
|
InvalidFieldMask: {
|
|
|
|
|
Message: "invalid field mask",
|
|
|
|
|
Kind: Parameter,
|
|
|
|
|
},
|
|
|
|
|
EmptyFieldMask: {
|
|
|
|
|
Message: "empty field mask",
|
|
|
|
|
Kind: Parameter,
|
|
|
|
|
},
|
2020-12-21 10:07:34 -08:00
|
|
|
PasswordTooShort: {
|
|
|
|
|
Message: "too short",
|
|
|
|
|
Kind: Password,
|
|
|
|
|
},
|
|
|
|
|
PasswordUnsupportedConfiguration: {
|
|
|
|
|
Message: "unable to support the password config type",
|
|
|
|
|
Kind: Password,
|
|
|
|
|
},
|
|
|
|
|
PasswordInvalidConfiguration: {
|
|
|
|
|
Message: "invalid parameters in password configuration",
|
|
|
|
|
Kind: Password,
|
|
|
|
|
},
|
|
|
|
|
PasswordsEqual: {
|
|
|
|
|
Message: "old and new password are equal",
|
|
|
|
|
Kind: Password,
|
|
|
|
|
},
|
2020-11-04 14:42:20 -05:00
|
|
|
CheckConstraint: {
|
|
|
|
|
Message: "constraint check failed",
|
|
|
|
|
Kind: Integrity,
|
|
|
|
|
},
|
|
|
|
|
NotNull: {
|
|
|
|
|
Message: "must not be empty (null) violation",
|
|
|
|
|
Kind: Integrity,
|
|
|
|
|
},
|
|
|
|
|
NotUnique: {
|
|
|
|
|
Message: "must be unique violation",
|
|
|
|
|
Kind: Integrity,
|
|
|
|
|
},
|
|
|
|
|
NotSpecificIntegrity: {
|
|
|
|
|
Message: "Integrity violation without specific details",
|
|
|
|
|
Kind: Integrity,
|
|
|
|
|
},
|
|
|
|
|
MissingTable: {
|
|
|
|
|
Message: "missing table",
|
|
|
|
|
Kind: Integrity,
|
|
|
|
|
},
|
2020-12-21 10:07:34 -08:00
|
|
|
ColumnNotFound: {
|
|
|
|
|
Message: "column not found",
|
|
|
|
|
Kind: Integrity,
|
|
|
|
|
},
|
2020-11-04 14:42:20 -05:00
|
|
|
RecordNotFound: {
|
|
|
|
|
Message: "record not found",
|
|
|
|
|
Kind: Search,
|
|
|
|
|
},
|
|
|
|
|
MultipleRecords: {
|
|
|
|
|
Message: "multiple records",
|
|
|
|
|
Kind: Search,
|
|
|
|
|
},
|
2020-12-21 10:07:34 -08:00
|
|
|
Exception: {
|
|
|
|
|
Message: "db exception",
|
|
|
|
|
Kind: Integrity,
|
|
|
|
|
},
|
|
|
|
|
MaxRetries: {
|
|
|
|
|
Message: "too many retries",
|
|
|
|
|
Kind: Transaction,
|
|
|
|
|
},
|
2020-11-04 14:42:20 -05:00
|
|
|
}
|