errors

package module
v0.0.0-...-1ef1be6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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 New

func New(format string, i ...interface{}) *Error

func NewWithKind

func NewWithKind(kind Kind, format string, i ...interface{}) *Error

func Wrap

func Wrap(err error, format string, i ...interface{}) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) FormatStacktrace

func (e *Error) FormatStacktrace() string

func (*Error) GetField

func (e *Error) GetField(key string) (value interface{}, ok bool)

func (*Error) Log

func (e *Error) Log() *logrus.Entry

func (*Error) Stacktrace

func (e *Error) Stacktrace() []string

func (*Error) StacktraceWithMessage

func (e *Error) StacktraceWithMessage() []string

func (*Error) WithField

func (e *Error) WithField(key string, value interface{}) *Error

func (*Error) WithFields

func (e *Error) WithFields(m map[string]interface{}) *Error

func (*Error) WithKind

func (e *Error) WithKind(kind Kind) *Error

func (*Error) WithMessage

func (e *Error) WithMessage(format string, i ...interface{}) *Error

func (*Error) WithOpHere

func (e *Error) WithOpHere() *Error

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"

	// KindUnavailable indicates the service is currently unavailable. This is a most
	// 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

func (k Kind) ToStatusCode() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL