errors

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromGRPCStatus

func FromGRPCStatus(st *status.Status, from, to service.Name) error

Types

type AbortError

type AbortError struct {
	Message    string
	InnerError error
}

func NewAbortError

func NewAbortError(message string, err error) *AbortError

NewAbortError creates an error that the API Start call must return internally.

func (*AbortError) Error

func (s *AbortError) Error() string

type Error

type Error struct {
	Code          int32  `json:"code"`
	ServiceName   string `json:"service_name,omitempty"`
	Message       string `json:"message,omitempty"`
	Destination   string `json:"destination,omitempty"`
	Kind          Kind   `json:"kind"`
	SubLevelError string `json:"details,omitempty"`
}

Error is the framework error type that a service handler should return to keep a standard error between services.

func (*Error) Error

func (e *Error) Error() string

func (*Error) String

func (e *Error) String() string

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

func NewFactory

func NewFactory(options FactoryOptions) *Factory

NewFactory creates a new Factory object.

func (*Factory) Custom

func (f *Factory) Custom(msg string) errors_api.Error

Custom lets a service set a custom error kind for its errors. Internally, it will be treated as an Internal error.

func (*Factory) FailedPrecondition

func (f *Factory) FailedPrecondition(message string) errors_api.Error

FailedPrecondition sets that the current error is related to an internal condition which wasn't satisfied.

func (*Factory) Internal

func (f *Factory) Internal(err error) errors_api.Error

Internal sets that the current error is related to an internal service error.

func (*Factory) InvalidArgument

func (f *Factory) InvalidArgument(err error) errors_api.Error

InvalidArgument sets that the current error is related to an argument that didn't follow validation rules.

func (*Factory) NotFound

func (f *Factory) NotFound() errors_api.Error

NotFound sets that the current error is related to some data not being found, probably in the database.

func (*Factory) PermissionDenied

func (f *Factory) PermissionDenied() errors_api.Error

PermissionDenied sets that the current error is related to a client trying to access a resource without having permission to do so.

func (*Factory) RPC

func (f *Factory) RPC(err error, destination string) errors_api.Error

RPC sets that the current error is related to an RPC call with another gRPC service (destination).

type FactoryOptions

type FactoryOptions struct {
	ServiceName string
	Logger      logger_api.LoggerAPI
}

type Kind added in v0.13.0

type Kind string

Kind is an error representation of a mapped error.

var (
	KindValidation   Kind = "ValidationError"
	KindInternal     Kind = "InternalError"
	KindNotFound     Kind = "NotFoundError"
	KindPrecondition Kind = "ConditionError"
	KindPermission   Kind = "PermissionError"
	KindRPC          Kind = "RPCError"
	KindCustom       Kind = "CustomError"
)

func (Kind) String added in v0.13.0

func (k Kind) String() string

type ServiceError

type ServiceError struct {
	// contains filtered or unexported fields
}

ServiceError is a structure that holds internal error details to improve error log description for the end-user, and it implements the errorApi.Error interface.

func (*ServiceError) Kind

func (s *ServiceError) Kind() string

func (*ServiceError) Submit

func (s *ServiceError) Submit(ctx context.Context) error

func (*ServiceError) WithAttributes

func (s *ServiceError) WithAttributes(attrs ...logger_api.Attribute) errors_api.Error

func (*ServiceError) WithCode

func (s *ServiceError) WithCode(code errors_api.Code) errors_api.Error

Jump to

Keyboard shortcuts

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