Documentation
¶
Overview ¶
Package errors contains helper functions and types to work with errors
Index ¶
- func BadRequestError(err error, message string) error
- func ConflictError(err error, message string) error
- func DependencyError(err error, message string) error
- func ForbiddenError(err error, message string) error
- func GeneralError(err error) error
- func GoneError(err error, message string) error
- func Is(err error, cat Category) bool
- func IsInternalError(err error) bool
- func NotSupportedError(err error, message string) error
- func ResourceNotFoundError(err error, message string) error
- func UnAuthorizedError(err error, message string) error
- type Category
- type ServiceError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequestError ¶
BadRequestError returns an error with category DataError the error message provided is returned to the user the error object provided is logged in logger
func ConflictError ¶
ConflictError returns an error with category CategoryDataConflict the error message provided is returned to the user the error object provided is logged in logger
func DependencyError ¶
DependencyError returns an error with category CategoryDependencyFailure. Use when a downstream service or store returns an unexpected error. The error message provided is returned to the user. The error object provided is logged in logger.
func ForbiddenError ¶
ForbiddenError returns a an error with category CategoryForbidden the error message provided is returned to the user the error object provided is logged in logger
func GeneralError ¶
GeneralError returns a general service error this error mesage sent to the user is "Internal Server Error" the error passed is logged in the logger
func GoneError ¶
GoneError returns an error with category CategoryGone (HTTP 410). Use when a resource existed but is no longer available (e.g. expired transfers).
func IsInternalError ¶
IsInternalError checks that provided error is a Internal system error
func NotSupportedError ¶
NotSupportedError returns an error with category NotSupported the error message provided is returned to the user the error object provided is logged in logger
func ResourceNotFoundError ¶
ResourceNotFoundError returns an error with category ResourceNotFound the error message provided is returned to the user the err object provided is logged in logger
func UnAuthorizedError ¶
UnAuthorizedError returns an error with category CategoryUnauthorized the error message provided is returned to the user the error object provided is logged in logger
Types ¶
type Category ¶
type Category int
Category defines error category
const ( // CategoryNoError is for the datadog request tracking, in case if internal services (GRPC) returns no error. CategoryNoError Category = iota // CategoryDataError The client sends some invalid data in the request, // for example, missing or incorrect content in the payload or parameters. // Could also represent a generic client error. CategoryDataError CategoryUnauthorized // CategoryForbidden The client is not authenticated to access the requested resource CategoryForbidden // CategoryResourceNotFound The client is attempting to access a resource that does not exist CategoryResourceNotFound // CategoryNotSupported The requested functionality is not supported CategoryNotSupported // CategoryDataConflict The client send some data that can create conflict with existing data CategoryDataConflict // CategoryLocked The client is not able to access the requested resource due to its locked state CategoryLocked // CategoryGone The resource existed but is no longer available (e.g. expired) CategoryGone // CategoryDependencyFailure A dependent service is throwing errors CategoryDependencyFailure // CategoryGeneralError The service failed in an unexpected way CategoryGeneralError // CategoryRecovering The service is failing but is expected to recover CategoryRecovering // CategoryConnectionTimeout Connection to a dependent service timing out CategoryConnectionTimeout )
type ServiceError ¶
ServiceError represents service specific type that is used all over the services.
func (ServiceError) Error ¶
func (err ServiceError) Error() string
Error method to comply with error interface
func (ServiceError) ErrorCode ¶
func (err ServiceError) ErrorCode() int
ErrorCode returns the JSON-RPC error code for this error category. This implements the rpc.Error interface from go-ethereum so that ServiceError values are encoded with the correct code in JSON-RPC responses.
func (ServiceError) Is ¶
func (err ServiceError) Is(target error) bool
Is implements the custom condition to check an error is equal to a service error
func (ServiceError) StatusCode ¶
func (err ServiceError) StatusCode() int
StatusCode returns the HTTP status code for the error category
func (ServiceError) Unwrap ¶
func (err ServiceError) Unwrap() error
Unwrap returns the underlying error