Documentation ¶
Index ¶
Constants ¶
View Source
const ( ErrorCodeOk = 0 //Not an error; returned on success. ErrorCodeCancelled = 1 //The operation was cancelled, typically by the caller. ErrorCodeUnknown = 2 //Unknown error. For example, this error may be returned when a Status value received from another address space belongs to an error space that is not known in this address space. Also errors raised by APIs that do not return enough error information may be converted to this error. ErrorCodeInvalidArgument = 3 // validation failed ErrorCodeDeadlineExceeded = 4 // deadline exceeded ErrorCodeNotFound = 5 // entity does not exist ErrorCodeConflict = 6 // action cannot be performed ErrorCodeNotAuthorized = 7 // requester does not have permissions to perform action ErrorCodeResourceExhausted = 8 // the resource has been exhausted ErrorCodeFailedPrecondition = 9 // operation was rejected because the system is not in a state required for the operation's execution ErrorCodeAborted = 10 // operation was aborted ErrorCodeOutOfRange = 11 // operation was attempted past the valid range ErrorCodeUnimplemented = 12 // the operation has not been implemented ErrorCodeInternal = 13 // internal error ErrorCodeDataLoss = 15 // unrecoverable data loss or corruption ErrorCodeUnauthenticated = 16 // requester is not authenticated )
Application error codes
Variables ¶
This section is empty.
Functions ¶
func ErrorMessageFromError ¶
ErrorMessage returns the human-readable message of the error, if available. Otherwise returns a generic error message.
func OperationFromError ¶ added in v0.2.0
Types ¶
type Error ¶
type Error struct { Code ErrorCode `json:"code"` Message string `json:"message"` Operation string `json:"operation"` Err error `json:"err"` }
func New ¶
func New(code ErrorCode, message string, opts ...ErrorOption) *Error
New creates and returns a new error
func Wrap ¶
Wrap returns a new error that contains the passed error but with a different operation, useful for creating stacktraces
func WrapWithOperation ¶ added in v0.2.0
Wrap returns a new error that contains the passed error but with a different operation, useful for creating stacktraces
func (*Error) GetHttpStatusCode ¶ added in v0.2.0
type ErrorCode ¶
type ErrorCode int
func ErrorCodeFromError ¶
ErrorCode returns the code of the root error, if available. Otherwise returns ErrorCodeInternal.
type ErrorInterface ¶
type ErrorOption ¶ added in v0.2.0
type ErrorOption func(*ErrorOptions)
func WithError ¶ added in v0.2.0
func WithError(err error) ErrorOption
func WithOperation ¶ added in v0.2.0
func WithOperation(operation string) ErrorOption
type ErrorOptions ¶ added in v0.2.0
Click to show internal directories.
Click to hide internal directories.