Documentation ¶
Index ¶
- Variables
- type ErrorCode
- type ExtendedError
- func ExtendedErrorFromDetail(details []interface{}) *ExtendedError
- func FromError(err error) *ExtendedError
- func FromGRPC(err error) *ExtendedError
- func NewAbortedError(format string, a ...interface{}) *ExtendedError
- func NewAbortedErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewAlreadyExistsError(format string, a ...interface{}) *ExtendedError
- func NewAlreadyExistsErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewCanceledError(format string, a ...interface{}) *ExtendedError
- func NewCanceledErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewDataLossError(format string, a ...interface{}) *ExtendedError
- func NewDataLossErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewDeadlineExceededError(format string, a ...interface{}) *ExtendedError
- func NewDeadlineExceededErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewExtendedError(code ErrorCode, format string, a ...interface{}) *ExtendedError
- func NewExtendedErrorFrom(code ErrorCode, err error, format string, a ...interface{}) *ExtendedError
- func NewFailedPreconditionError(format string, a ...interface{}) *ExtendedError
- func NewFailedPreconditionErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewInternalError(format string, a ...interface{}) *ExtendedError
- func NewInternalErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewInvalidArgumentError(format string, a ...interface{}) *ExtendedError
- func NewInvalidArgumentErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewNotFoundError(format string, a ...interface{}) *ExtendedError
- func NewNotFoundErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewOutOfRangeError(format string, a ...interface{}) *ExtendedError
- func NewOutOfRangeErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewPermissionDeniedError(format string, a ...interface{}) *ExtendedError
- func NewPermissionDeniedErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewResourceExhaustedError(format string, a ...interface{}) *ExtendedError
- func NewResourceExhaustedErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewUnauthenticatedError(format string, a ...interface{}) *ExtendedError
- func NewUnauthenticatedErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewUnavailableError(format string, a ...interface{}) *ExtendedError
- func NewUnavailableErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewUnimplementedError(format string, a ...interface{}) *ExtendedError
- func NewUnimplementedErrorFrom(err error, format string, a ...interface{}) *ExtendedError
- func NewUnknownError(format string, a ...interface{}) *ExtendedError
- func NewUnknownErrorFrom(err error, format string, a ...interface{}) *ExtendedError
Constants ¶
This section is empty.
Variables ¶
var FromGRPCCode = map[codes.Code]ErrorCode{ codes.OK: OK, codes.Canceled: Canceled, codes.Unknown: Unknown, codes.InvalidArgument: InvalidArgument, codes.DeadlineExceeded: DeadlineExceeded, codes.NotFound: NotFound, codes.AlreadyExists: AlreadyExists, codes.PermissionDenied: PermissionDenied, codes.ResourceExhausted: ResourceExhausted, codes.FailedPrecondition: FailedPrecondition, codes.Aborted: Aborted, codes.OutOfRange: OutOfRange, codes.Unimplemented: Unimplemented, codes.Internal: Internal, codes.Unavailable: Unavailable, codes.DataLoss: DataLoss, codes.Unauthenticated: Unauthenticated, }
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, }
var ToGRPCCode = map[ErrorCode]codes.Code{ OK: codes.OK, Canceled: codes.Canceled, Unknown: codes.Unknown, InvalidArgument: codes.InvalidArgument, DeadlineExceeded: codes.DeadlineExceeded, NotFound: codes.NotFound, AlreadyExists: codes.AlreadyExists, PermissionDenied: codes.PermissionDenied, ResourceExhausted: codes.ResourceExhausted, FailedPrecondition: codes.FailedPrecondition, Aborted: codes.Aborted, OutOfRange: codes.OutOfRange, Unimplemented: codes.Unimplemented, Internal: codes.Internal, Unavailable: codes.Unavailable, DataLoss: codes.DataLoss, Unauthenticated: codes.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 // 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
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)