Documentation
¶
Index ¶
- func IsBadRequest(err error) bool
- func IsCannotProcess(err error) bool
- func IsClientError(err error) bool
- func IsConflict(err error) bool
- func IsDuplicate(err error) bool
- func IsInternalError(err error) bool
- func IsNotAuthenticated(err error) bool
- func IsNotAuthorised(err error) bool
- func IsNotFound(err error) bool
- func IsRetryable(err error) bool
- func IsTooManyRequests(err error) bool
- func IsUnavailable(err error) bool
- type BadRequest
- type CannotProcess
- type ClientError
- type Conflict
- type Duplicate
- type InternalError
- type NotAuthenticated
- type NotAuthorised
- type NotFound
- type Retryable
- type TooManyRequests
- type Unavailable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBadRequest ¶
IsBadRequest will check that an error is a BadRequest type.
func IsCannotProcess ¶
IsCannotProcess will check that an error is a CannotProcess type.
func IsClientError ¶
IsClientError is return true if the provided error was of the clientError type.
func IsConflict ¶ added in v0.0.12
IsConflict will check if this is a conflict error.
func IsDuplicate ¶
IsDuplicate can be used throughout your code or in an error handler to check that an err is a Duplicate error. If so, true is returned.
func IsInternalError ¶
IsInternalError will return true if this is an InternalError.
func IsNotAuthenticated ¶
IsNotAuthenticated will check that an error is a NotAuthenticated type.
func IsNotAuthorised ¶
IsNotAuthorised will check that and error or it's cause was of the NotAuthorised type.
func IsNotFound ¶
IsNotFound can be used throughout your code or in an error handler to check that an err is a NotFound error. If so, true is returned.
func IsRetryable ¶ added in v0.0.7
IsRetryable will check that an error is a Retryable type.
func IsTooManyRequests ¶ added in v0.0.11
IsTooManyRequests will check if this is a tooManyRequests error.
func IsUnavailable ¶
IsUnavailable will check that an error is an Unavailable type.
Types ¶
type BadRequest ¶
type BadRequest interface {
BadRequest() bool
}
BadRequest when implemented will indicate that the error is a BadRequest error to be returned when user input is invalid.
type CannotProcess ¶
type CannotProcess interface {
CannotProcess() bool
}
CannotProcess when implemented will indicate that the request can no longer be processed.
type ClientError ¶
type ClientError interface { // ID can contain a correlationID/requestID etc. ID() string // Code can contain an error code relating to the type of error. Code() string // Title should not change between errors ie all NotFound errors should have the same title. Title() string // Detail will return human readable detail. Detail() string error }
ClientError defines an error that could be returned to a caller. It should not expose debug or program information but rather useful information for a consuming client. This can be called to build a message type of your choosing to match the transport being used by the server such as http, grpc etc.
type Conflict ¶ added in v0.0.12
type Conflict interface {
Conflict() bool
}
Conflict when implemented will indicate that the request cannot be completed due to a conflict with the current state of the resource.
type Duplicate ¶
type Duplicate interface {
Duplicate() bool
}
Duplicate when implemented will indicate that the error is a Duplicate error.
type InternalError ¶
type InternalError interface { // ID is a unique id for this particular message to help identification ID() string // Code is an optional error code, all erorrs of the same reason could have // a code assigned for machine handling of errors. Code() string // Message is the human readable reason for the error. Message() string // Stack is the full stack trace of the error, you may want to redact this in production environments. Stack() string // Metadata can be used to provide structured fields to an error message. Metadata() map[string]interface{} }
InternalError can be implemented to create errors used to capture internal faults. These could then be sent to an error logging system to be rectified. In terms of a web server, this would be a 5XX error.
type NotAuthenticated ¶
type NotAuthenticated interface {
NotAuthenticated() bool
}
NotAuthenticated when implemented will indicate that the error is a NotAuthenticated error.
type NotAuthorised ¶
type NotAuthorised interface {
NotAuthorised() bool
}
NotAuthorised when implemented will indicate that the error is a NotAuthorised error.
type NotFound ¶
type NotFound interface {
NotFound() bool
}
NotFound when implemented will indicate that the error is a NotFound error.
type Retryable ¶ added in v0.0.7
type Retryable interface {
Retryable() bool
}
Retryable when implemented will indicate that the error is retryable at which point you can try to re-submit as there is a chance it could succeed.
type TooManyRequests ¶ added in v0.0.11
type TooManyRequests interface {
TooManyRequests() bool
}
TooManyRequests when implemented will indicate that too many requests have occurred and the system cannot handle any further requests.
type Unavailable ¶
type Unavailable interface {
}Unavailable when implemented will indicate that the service is not currently available. This could also be returned if a database or critical dependency isn't reachable.