Documentation ¶
Index ¶
- Variables
- type Error
- func (e *Error) Error() string
- func (e *Error) FormatStacktrace() string
- func (e *Error) GetField(key string) (value interface{}, ok bool)
- func (e *Error) Log() *logrus.Entry
- func (e *Error) Stacktrace() []string
- func (e *Error) StacktraceWithMessage() []string
- func (e *Error) WithField(key string, value interface{}) *Error
- func (e *Error) WithFields(m map[string]interface{}) *Error
- func (e *Error) WithKind(kind Kind) *Error
- func (e *Error) WithMessage(format string, i ...interface{}) *Error
- func (e *Error) WithOpHere() *Error
- type Kind
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ColorBlack = "\033[1;30m" ColorRed = "\033[1;31m" ColorGreen = "\033[1;32m" ColorYellow = "\033[1;33m" ColorPurple = "\033[1;34m" ColorMagenta = "\033[1;35m" ColorTeal = "\033[1;36m" ColorWhite = "\033[1;37m" ColorReset = "\u001B[0m" )
View Source
var KindToStatusCodeHook = func(k Kind) int { return http.StatusInternalServerError }
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { // Kind represent the type of error Kind Kind // Message is the information about the error Message string // the wrapped error Err error // contains filtered or unexported fields }
func NewWithKind ¶
func (*Error) FormatStacktrace ¶
func (*Error) Stacktrace ¶
func (*Error) StacktraceWithMessage ¶
func (*Error) WithFields ¶
func (*Error) WithMessage ¶
func (*Error) WithOpHere ¶
type Kind ¶
type Kind string
const ( // KindCanceled indicates the operation was cancelled (typically by the caller). KindCanceled Kind = "canceled" // KindUnknown error. For example when handling errors raised by APIs that do not // return enough error information. KindUnknown Kind = "unknown" // KindInvalidArgument indicates client specified an invalid argument. It // indicates arguments that are problematic regardless of the state of the // system (i.e. a malformed file name, required argument, number out of range, // etc.). KindInvalidArgument Kind = "invalid_argument" // KindDeadlineExceeded means operation expired before completion. For operations // that change the state of the system, this error may be returned even if the // operation has completed successfully (timeout). KindDeadlineExceeded Kind = "deadline_exceeded" // KindNotFound means some requested entity was not found. KindNotFound Kind = "not_found" // AlreadyExists means an attempt to create an entity failed because one // already exists. KindAlreadyExists Kind = "already_exists" // KindPermissionDenied indicates the caller does not have permission to execute // the specified operation. It must not be used if the caller cannot be // identified (Unauthenticated). KindPermissionDenied Kind = "permission_denied" // KindUnauthenticated indicates the request does not have valid authentication // credentials for the operation. KindUnauthenticated Kind = "unauthenticated" // KindResourceExhausted indicates some resource has been exhausted, perhaps a // per-user quota, or perhaps the entire file system is out of space. KindResourceExhausted Kind = "resource_exhausted" // KindFailedPrecondition indicates operation was rejected because the system is // not in a state required for the operation's execution. For example, doing // an rmdir operation on a directory that is non-empty, or on a non-directory // object, or when having conflicting read-modify-write on the same resource. KindFailedPrecondition Kind = "failed_precondition" // KindAborted indicates the operation was aborted, typically due to a concurrency // issue like sequencer check failures, transaction aborts, etc. KindAborted Kind = "aborted" // KindOutOfRange means operation was attempted past the valid range. For example, // seeking or reading past end of a paginated collection. // // Unlike InvalidArgument, this error indicates a problem that may be fixed if // the system state changes (i.e. adding more items to the collection). // // There is a fair bit of overlap between FailedPrecondition and OutOfRange. // We recommend using OutOfRange (the more specific error) when it applies so // that callers who are iterating through a space can easily look for an // OutOfRange error to detect when they are done. KindOutOfRange Kind = "out_of_range" // KindUnimplemented indicates operation is not implemented or not // supported/enabled in this service. KindUnimplemented Kind = "unimplemented" // KindInternal errors. When some invariants expected by the underlying system // have been broken. In other words, something bad happened in the library or // backend service. Do not confuse with HTTP Internal Server Error; an // Internal error could also happen on the client code, i.e. when parsing a // server response. KindInternal Kind = "internal" // likely a transient condition and may be corrected by retrying with a // backoff. KindUnavailable Kind = "unavailable" // DataLoss indicates unrecoverable data loss or corruption. KindDataLoss Kind = "data_loss" // KindNone is the zero-value, is considered an empty error and should not be // used. KindNone Kind = "" )
func (Kind) ToStatusCode ¶
Click to show internal directories.
Click to hide internal directories.