Documentation
¶
Index ¶
- func CodeStr(code ServiceErrorCode) *string
- func ErrorCodePrefix() string
- func ErrorHrefBase() string
- func Href(code ServiceErrorCode) *string
- func SetErrorCodePrefix(prefix string)
- func SetErrorHref(href string)
- type ServiceError
- func BadRequest(reason string, values ...interface{}) *ServiceError
- func Conflict(reason string, values ...interface{}) *ServiceError
- func DatabaseAdvisoryLock(err error) *ServiceError
- func FailedToParseSearch(reason string, values ...interface{}) *ServiceError
- func Find(code ServiceErrorCode) (bool, *ServiceError)
- func Forbidden(reason string, values ...interface{}) *ServiceError
- func GeneralError(reason string, values ...interface{}) *ServiceError
- func MalformedRequest(reason string, values ...interface{}) *ServiceError
- func New(code ServiceErrorCode, reason string, values ...interface{}) *ServiceError
- func NotFound(reason string, values ...interface{}) *ServiceError
- func NotImplemented(reason string, values ...interface{}) *ServiceError
- func Unauthenticated(reason string, values ...interface{}) *ServiceError
- func Unauthorized(reason string, values ...interface{}) *ServiceError
- func Validation(reason string, values ...interface{}) *ServiceError
- type ServiceErrorCode
- type ServiceErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CodeStr ¶
func CodeStr(code ServiceErrorCode) *string
func ErrorCodePrefix ¶
func ErrorCodePrefix() string
func ErrorHrefBase ¶
func ErrorHrefBase() string
func Href ¶
func Href(code ServiceErrorCode) *string
func SetErrorCodePrefix ¶
func SetErrorCodePrefix(prefix string)
func SetErrorHref ¶
func SetErrorHref(href string)
Types ¶
type ServiceError ¶
type ServiceError struct {
// Code is the numeric and distinct ID for the error
Code ServiceErrorCode
// Reason is the context-specific reason the error was generated
Reason string
// HttopCode is the HttpCode associated with the error when the error is returned as an API response
HttpCode int
}
func BadRequest ¶
func BadRequest(reason string, values ...interface{}) *ServiceError
func Conflict ¶
func Conflict(reason string, values ...interface{}) *ServiceError
func DatabaseAdvisoryLock ¶
func DatabaseAdvisoryLock(err error) *ServiceError
func FailedToParseSearch ¶
func FailedToParseSearch(reason string, values ...interface{}) *ServiceError
func Find ¶
func Find(code ServiceErrorCode) (bool, *ServiceError)
func Forbidden ¶
func Forbidden(reason string, values ...interface{}) *ServiceError
func GeneralError ¶
func GeneralError(reason string, values ...interface{}) *ServiceError
func MalformedRequest ¶
func MalformedRequest(reason string, values ...interface{}) *ServiceError
func New ¶
func New(code ServiceErrorCode, reason string, values ...interface{}) *ServiceError
New Reason can be a string with format verbs, which will be replace by the specified values
func NotFound ¶
func NotFound(reason string, values ...interface{}) *ServiceError
func NotImplemented ¶
func NotImplemented(reason string, values ...interface{}) *ServiceError
func Unauthenticated ¶
func Unauthenticated(reason string, values ...interface{}) *ServiceError
func Unauthorized ¶
func Unauthorized(reason string, values ...interface{}) *ServiceError
func Validation ¶
func Validation(reason string, values ...interface{}) *ServiceError
func (*ServiceError) AsError ¶
func (e *ServiceError) AsError() error
func (*ServiceError) AsOpenapiError ¶
func (e *ServiceError) AsOpenapiError(operationID string) openapi.Error
func (*ServiceError) Error ¶
func (e *ServiceError) Error() string
func (*ServiceError) Is404 ¶
func (e *ServiceError) Is404() bool
func (*ServiceError) IsConflict ¶
func (e *ServiceError) IsConflict() bool
func (*ServiceError) IsForbidden ¶
func (e *ServiceError) IsForbidden() bool
type ServiceErrorCode ¶
type ServiceErrorCode int
const ( // InvalidToken occurs when a token is invalid (generally, not found in the database) ErrorInvalidToken ServiceErrorCode = 1 // Forbidden occurs when a user has been blacklisted ErrorForbidden ServiceErrorCode = 4 // Conflict occurs when a database constraint is violated ErrorConflict ServiceErrorCode = 6 // NotFound occurs when a record is not found in the database ErrorNotFound ServiceErrorCode = 7 // Validation occurs when an object fails validation ErrorValidation ServiceErrorCode = 8 // General occurs when an error fails to match any other error code ErrorGeneral ServiceErrorCode = 9 // NotImplemented occurs when an API REST method is not implemented in a handler ErrorNotImplemented ServiceErrorCode = 10 ErrorUnauthorized ServiceErrorCode = 11 // Unauthenticated occurs when the provided credentials cannot be validated ErrorUnauthenticated ServiceErrorCode = 15 // MalformedRequest occurs when the request body cannot be read ErrorMalformedRequest ServiceErrorCode = 17 // Bad Request ErrorBadRequest ServiceErrorCode = 21 // Invalid Search Query ErrorFailedToParseSearch ServiceErrorCode = 23 // DatabaseAdvisoryLock occurs whe the advisory lock is failed to get ErrorDatabaseAdvisoryLock ServiceErrorCode = 26 )
Click to show internal directories.
Click to hide internal directories.