Documentation ¶
Overview ¶
Package errors provides a way to create, manipulate and manage typed errors which contains stack trace information.
All signare code inside the domain and application layers must use it.
Index ¶
- func IsAlreadyExists(err error) bool
- func IsBadGateway(err error) bool
- func IsInternal(err error) bool
- func IsInvalidArgument(err error) bool
- func IsNotFound(err error) bool
- func IsNotImplemented(err error) bool
- func IsPermissionDenied(err error) bool
- func IsPreconditionFailed(err error) bool
- func IsTimeout(err error) bool
- func IsTooManyReq(err error) bool
- func IsUnauthenticated(err error) bool
- func IsUnavailable(err error) bool
- type ErrorType
- type PrivateError
- type PublicError
- func AlreadyExists() *PublicError
- func AlreadyExistsFromErr(err error) *PublicError
- func BadGateway() *PublicError
- func BadGatewayFromErr(err error) *PublicError
- func InvalidArgument() *PublicError
- func InvalidArgumentFromErr(err error) *PublicError
- func NotFound() *PublicError
- func NotFoundFromErr(err error) *PublicError
- func NotImplemented() *PublicError
- func NotImplementedFromErr(err error) *PublicError
- func PreconditionFailed() *PublicError
- func PreconditionFailedFromErr(err error) *PublicError
- func Timeout() *PublicError
- func TimeoutFromErr(err error) *PublicError
- func TooManyReq() *PublicError
- func TooManyReqFromErr(err error) *PublicError
- func Unauthenticated() *PublicError
- func UnauthenticatedFromErr(err error) *PublicError
- func Unavailable() *PublicError
- func UnavailableFromErr(err error) *PublicError
- type UseCaseError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyExists ¶
IsAlreadyExists checks whether the target error is of type ErrAlreadyExists.
func IsBadGateway ¶
IsBadGateway checks whether the target error is of type ErrBadGateway.
func IsInternal ¶
IsInternal checks whether the target error is of type ErrInternal.
func IsInvalidArgument ¶
IsInvalidArgument checks whether the target error is of type ErrInvalidArgument.
func IsNotFound ¶
IsNotFound checks whether the target error is of type ErrNotFound.
func IsNotImplemented ¶
IsNotImplemented checks whether the target error is of type ErrNotImplemented.
func IsPermissionDenied ¶
IsPermissionDenied checks whether the target error is of type ErrPermissionDenied.
func IsPreconditionFailed ¶
IsPreconditionFailed checks whether the target error is of type ErrPreconditionFailed.
func IsTooManyReq ¶
IsTooManyReq checks whether the target error is of type ErrTooManyReq.
func IsUnauthenticated ¶
IsUnauthenticated checks whether the target error is of type ErrUnauthenticated.
func IsUnavailable ¶
IsUnavailable checks whether the target error is of type ErrUnavailable.
Types ¶
type ErrorType ¶
type ErrorType string
ErrorType associated with the PrivateError.
const ( ErrInvalidArgument ErrorType = "INVALID_ARGUMENT" ErrPreconditionFailed ErrorType = "PRECONDITION_FAILED" ErrUnauthenticated ErrorType = "UNAUTHENTICATED" ErrPermissionDenied ErrorType = "PERMISSION_DENIED" ErrNotFound ErrorType = "NOT_FOUND" ErrAlreadyExists ErrorType = "ALREADY_EXISTS" ErrNotImplemented ErrorType = "NOT_IMPLEMENTED" ErrBadGateway ErrorType = "BAD_GATEWAY" ErrTimeout ErrorType = "TIMEOUT" ErrTooManyReq ErrorType = "TOO_MANY_REQ" ErrInternal ErrorType = "INTERNAL" )
type PrivateError ¶
type PrivateError struct {
// contains filtered or unexported fields
}
PrivateError is a traceable error that does not allow to edit the message to explain the reason behind it.
func Internal ¶
func Internal() *PrivateError
Internal returns a new PrivateError of type ErrInternal.
func InternalFromErr ¶
func InternalFromErr(err error) *PrivateError
InternalFromErr returns a new PrivateError of type ErrInternal wrapping the original error.
func PermissionDenied ¶
func PermissionDenied() *PrivateError
PermissionDenied returns a new PrivateError of type ErrPermissionDenied.
func PermissionDeniedFromErr ¶
func PermissionDeniedFromErr(err error) *PrivateError
PermissionDeniedFromErr returns a new PrivateError of type ErrPermissionDenied wrapping the original error.
func (*PrivateError) Error ¶
func (e *PrivateError) Error() string
PrivateError implements the built-in error interface. It returns all available error information, including inner errors that are wrapped by this error.
func (*PrivateError) GetStack ¶
func (e *PrivateError) GetStack() string
GetStack returns the PrivateError's stack trace.
func (*PrivateError) HumanReadableMessage ¶
func (e *PrivateError) HumanReadableMessage() *string
HumanReadableMessage retrieves the message associated with the error or nil if there isn't one. This message may be outputted outside the application.
func (*PrivateError) Type ¶
func (e *PrivateError) Type() ErrorType
Type returns the PrivateError Type
func (*PrivateError) WithMessage ¶
func (e *PrivateError) WithMessage(format string, args ...any) *PrivateError
WithMessage allows to extend the error message.
type PublicError ¶
type PublicError struct {
PrivateError
}
PublicError is a traceable error that allows to edit the message to explain the reason behind it.
func AlreadyExists ¶
func AlreadyExists() *PublicError
AlreadyExists returns a new PrivateError of type ErrAlreadyExists.
func AlreadyExistsFromErr ¶
func AlreadyExistsFromErr(err error) *PublicError
AlreadyExistsFromErr returns a new PrivateError of type ErrAlreadyExists wrapping the original error.
func BadGateway ¶
func BadGateway() *PublicError
BadGateway returns a new PrivateError of type ErrBadGateway.
func BadGatewayFromErr ¶
func BadGatewayFromErr(err error) *PublicError
BadGatewayFromErr returns a new PrivateError of type ErrBadGateway wrapping the original error.
func InvalidArgument ¶
func InvalidArgument() *PublicError
InvalidArgument returns a new PrivateError of type ErrInvalidArgument.
func InvalidArgumentFromErr ¶
func InvalidArgumentFromErr(err error) *PublicError
InvalidArgumentFromErr returns a new PrivateError of type ErrInvalidArgument wrapping the original error.
func NotFound ¶
func NotFound() *PublicError
NotFound returns a new PrivateError of type ErrNotFound.
func NotFoundFromErr ¶
func NotFoundFromErr(err error) *PublicError
NotFoundFromErr returns a new PrivateError of type ErrNotFound wrapping the original error.
func NotImplemented ¶
func NotImplemented() *PublicError
NotImplemented returns a new PrivateError of type ErrNotImplemented.
func NotImplementedFromErr ¶
func NotImplementedFromErr(err error) *PublicError
NotImplementedFromErr returns a new PrivateError of type ErrNotImplemented wrapping the original error.
func PreconditionFailed ¶
func PreconditionFailed() *PublicError
PreconditionFailed returns a new PrivateError of type ErrPreconditionFailed.
func PreconditionFailedFromErr ¶
func PreconditionFailedFromErr(err error) *PublicError
PreconditionFailedFromErr returns a new PrivateError of type ErrPreconditionFailed wrapping the original error.
func TimeoutFromErr ¶
func TimeoutFromErr(err error) *PublicError
TimeoutFromErr returns a new PrivateError of type ErrTimeout wrapping the original error.
func TooManyReq ¶
func TooManyReq() *PublicError
TooManyReq returns a new PrivateError of type ErrTooManyReq.
func TooManyReqFromErr ¶
func TooManyReqFromErr(err error) *PublicError
TooManyReqFromErr returns a new PrivateError of type ErrTooManyReq wrapping the original error.
func Unauthenticated ¶
func Unauthenticated() *PublicError
Unauthenticated returns a new PrivateError of type ErrUnauthenticated.
func UnauthenticatedFromErr ¶
func UnauthenticatedFromErr(err error) *PublicError
UnauthenticatedFromErr returns a new PrivateError of type ErrUnauthenticated wrapping the original error.
func Unavailable ¶
func Unavailable() *PublicError
Unavailable returns a new PrivateError of type ErrUnavailable.
func UnavailableFromErr ¶
func UnavailableFromErr(err error) *PublicError
UnavailableFromErr returns a new PrivateError of type ErrUnavailable wrapping the original error.
func (*PublicError) SetHumanReadableMessage ¶
func (e *PublicError) SetHumanReadableMessage(format string, args ...any) *PublicError
SetHumanReadableMessage allows to set a message associated with the error that can be read from outside the application. Only UseCases should set human-readable messages.
func (*PublicError) WithMessage ¶
func (e *PublicError) WithMessage(format string, args ...any) *PublicError
WithMessage allows to extend the error message.
type UseCaseError ¶
type UseCaseError interface { error Type() ErrorType GetStack() string HumanReadableMessage() *string }
func CastAsUseCaseError ¶
func CastAsUseCaseError(err error) (UseCaseError, bool)
CastAsUseCaseError casts the provided error as an internal error type
Source Files ¶
- error_already_exists.go
- error_bad_gateway.go
- error_internal.go
- error_invalid_argument.go
- error_not_found.go
- error_not_implemented.go
- error_permission_denied.go
- error_precondition_failed.go
- error_timeout.go
- error_too_many_requests.go
- error_unauthenticated.go
- error_unavailable.go
- errors.go
- private_errors.go
- public_errors.go