nerrors

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: Apache-2.0 Imports: 8 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FromStringCode = map[string]ErrorCode{
	"OK":                 OK,
	"Canceled":           Canceled,
	"Unknown":            Unknown,
	"InvalidArgument":    InvalidArgument,
	"DeadlineExceeded":   DeadlineExceeded,
	"NotFound":           NotFound,
	"AlreadyExists":      AlreadyExists,
	"PermissionDenied":   PermissionDenied,
	"ResourceExhausted":  ResourceExhausted,
	"FailedPrecondition": FailedPrecondition,
	"Aborted":            Aborted,
	"OutOfRange":         OutOfRange,
	"Unimplemented":      Unimplemented,
	"Internal":           Internal,
	"Unavailable":        Unavailable,
	"DataLoss":           DataLoss,
	"Unauthenticated":    Unauthenticated,
}

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode int
const (
	// Ok indicates that this is not an error. This value is useful as enum use zero to represent the first element, and that information may not be sent through gRPC.
	OK ErrorCode = iota
	// Canceled indicates an operation was canceled and will no longer be executed.
	Canceled
	// Unknown indicates that while an error happened, its type is not known.
	Unknown
	// InvalidArgument indicates an error was detected due to the use of an invalid argument (e.g., invalid value).
	InvalidArgument
	// DeadlineExceeded indicates that the deadline expired before the operation could complete.
	DeadlineExceeded
	// NotFound indicates that some information about the requested entity was not found.
	NotFound
	// AlreadyExists indicates that an operation failed to create an entity because it already exists.
	AlreadyExists
	// PermissionDenied indicates that the caller does not have permission to execute the specified operation.
	PermissionDenied
	// ResourceExhausted indicates that the requested resource has been exhaused (e.g., no more pages exists).
	ResourceExhausted
	// FailedPrecondition indicates that an operation failed to satisfy a required precondition for its execution (e.g., base namespace was not created).
	FailedPrecondition
	// Aborted indicates that an operation was aborted due to some triggering factor.
	Aborted
	// OutOfRange indicates that an operation tried to access an element past the valid range.
	OutOfRange
	// Unimplemented indicates that the requested operation while declared is not implemented.
	Unimplemented
	// Internal indicates that an internal error in some component or system prevented the operation to be executed or failed during its execution.
	Internal
	// Unavailable indicates that the requested entity or operation is not available at this point.
	Unavailable
	// DataLoss indicates that an error related to unrecoverable data loss or corruption has happened.
	DataLoss
	// Unauthenticated indicates that the request does not have valid authentication credentials for the operation.
	Unauthenticated
)

https://github.com/grpc/grpc/blob/master/doc/statuscodes.md ErrorCode compatible with gRPC codes

func (ErrorCode) String

func (ec ErrorCode) String() string

type ExtendedError

type ExtendedError struct {
	// Code with the type of the error (compatible with GRPC)
	Code ErrorCode
	// Msg with a textual description of the error.
	Msg string
	// From links with the parent error if any.
	From error
	// StackTrace related to where the error happened in the code base.
	StackTrace []string
}

ExtendedError with an extended golang error

func ExtendedErrorFromDetail

func ExtendedErrorFromDetail(details []interface{}) *ExtendedError

ExtendedErrorFromDetail create an extended error from the details of the grpc error

func FromError

func FromError(err error) *ExtendedError

FromError transforms a standard go error into an extended error

func FromGRPC

func FromGRPC(err error) *ExtendedError

FromGRPC converts a GrpcError to an extended error

func NewAbortedError

func NewAbortedError(format string, a ...interface{}) *ExtendedError

func NewAbortedErrorFrom

func NewAbortedErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewAlreadyExistsError

func NewAlreadyExistsError(format string, a ...interface{}) *ExtendedError

func NewAlreadyExistsErrorFrom

func NewAlreadyExistsErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewCanceledError

func NewCanceledError(format string, a ...interface{}) *ExtendedError

func NewCanceledErrorFrom

func NewCanceledErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewDataLossError

func NewDataLossError(format string, a ...interface{}) *ExtendedError

func NewDataLossErrorFrom

func NewDataLossErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewDeadlineExceededError

func NewDeadlineExceededError(format string, a ...interface{}) *ExtendedError

func NewDeadlineExceededErrorFrom

func NewDeadlineExceededErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewExtendedError

func NewExtendedError(code ErrorCode, format string, a ...interface{}) *ExtendedError

NewExtendedError generic method to create an extended error

func NewExtendedErrorFrom

func NewExtendedErrorFrom(code ErrorCode, err error,
	format string, a ...interface{}) *ExtendedError

NewExtendedError From generic method to create an extended error from another caused by another one

func NewFailedPreconditionError

func NewFailedPreconditionError(format string, a ...interface{}) *ExtendedError

func NewFailedPreconditionErrorFrom

func NewFailedPreconditionErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewInternalError

func NewInternalError(format string, a ...interface{}) *ExtendedError

func NewInternalErrorFrom

func NewInternalErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewInvalidArgumentError

func NewInvalidArgumentError(format string, a ...interface{}) *ExtendedError

func NewInvalidArgumentErrorFrom

func NewInvalidArgumentErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewNotFoundError

func NewNotFoundError(format string, a ...interface{}) *ExtendedError

func NewNotFoundErrorFrom

func NewNotFoundErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewOutOfRangeError

func NewOutOfRangeError(format string, a ...interface{}) *ExtendedError

func NewOutOfRangeErrorFrom

func NewOutOfRangeErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewPermissionDeniedError

func NewPermissionDeniedError(format string, a ...interface{}) *ExtendedError

func NewPermissionDeniedErrorFrom

func NewPermissionDeniedErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewResourceExhaustedError

func NewResourceExhaustedError(format string, a ...interface{}) *ExtendedError

func NewResourceExhaustedErrorFrom

func NewResourceExhaustedErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewUnauthenticatedError

func NewUnauthenticatedError(format string, a ...interface{}) *ExtendedError

func NewUnauthenticatedErrorFrom

func NewUnauthenticatedErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewUnavailableError

func NewUnavailableError(format string, a ...interface{}) *ExtendedError

func NewUnavailableErrorFrom

func NewUnavailableErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewUnimplementedError

func NewUnimplementedError(format string, a ...interface{}) *ExtendedError

func NewUnimplementedErrorFrom

func NewUnimplementedErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func NewUnknownError

func NewUnknownError(format string, a ...interface{}) *ExtendedError

func NewUnknownErrorFrom

func NewUnknownErrorFrom(err error, format string, a ...interface{}) *ExtendedError

func (*ExtendedError) Error

func (ee *ExtendedError) Error() string

Error method to implement error interface

func (*ExtendedError) ShortString

func (ee *ExtendedError) ShortString() string

func (*ExtendedError) StackTraceToString

func (ee *ExtendedError) StackTraceToString() string

StackTraceToString loops through error chain showing stack trace

func (*ExtendedError) String

func (ee *ExtendedError) String() string

func (*ExtendedError) ToGRPC

func (ee *ExtendedError) ToGRPC() error

TODO: in the next version, instead of use DebugInfo and compose a detail, we can implement our own protoiface.MessageV1 ToGRPC converts an extended error to a GrpcError

func (*ExtendedError) Unwrap

func (ee *ExtendedError) Unwrap() error

Unwrap method to implement Wrapper interface (provides context around another error)

Jump to

Keyboard shortcuts

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