Documentation ¶
Index ¶
- Constants
- type AbortError
- type Error
- type ErrorKind
- type Factory
- func (f *Factory) Custom(msg string) errorsApi.Error
- func (f *Factory) FailedPrecondition(message string) errorsApi.Error
- func (f *Factory) Internal(err error) errorsApi.Error
- func (f *Factory) InvalidArgument(err error) errorsApi.Error
- func (f *Factory) NotFound() errorsApi.Error
- func (f *Factory) PermissionDenied() errorsApi.Error
- func (f *Factory) RPC(err error, destination string) errorsApi.Error
- type FactoryOptions
- type ServiceError
Constants ¶
const ( CodeInternal int32 = iota + 1 CodeNotFound CodeInvalidArgument CodePreconditionFailed CodeNoPermission CodeRPC )
Internal error codes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbortError ¶
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 ErrorKind `json:"kind"` SublevelError string `json:"details,omitempty"` // contains filtered or unexported fields }
Error is the framework error type that a service handler should return to keep a standard error between services.
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 ¶
Custom lets a service set a custom error kind for its errors. Internally, it will be treated as an Internal error.
func (*Factory) FailedPrecondition ¶
FailedPrecondition sets that the current error is related to an internal condition which wasn't satisfied.
func (*Factory) Internal ¶
Internal sets that the current error is related to an internal service error.
func (*Factory) InvalidArgument ¶
InvalidArgument sets that the current error is related to an argument that didn't follow validation rules.
func (*Factory) NotFound ¶
NotFound sets that the current error is related to some data not being found, probably in the database.
func (*Factory) PermissionDenied ¶
PermissionDenied sets that the current error is related to a client trying to access a resource without having permission to do so.
type FactoryOptions ¶
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) WithAttributes ¶
func (s *ServiceError) WithAttributes(attrs ...loggerApi.Attribute) errorsApi.Error