Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPermission is the standard "Permission Denied" error // nolint: stylecheck // this a special error that is displayed to the user as it is. ErrPermission = errors.New("You don't have required permission to perform this action") // ErrAuthorization is the standard "Unauthorized" error // nolint: stylecheck // this a special error that is displayed to the user as it is. ErrAuthorization = errors.New("User is unauthorized, make sure you've logged in") // ErrInternal is the standard "Internal Server" error // nolint: stylecheck // this a special error that is displayed to the user as it is. ErrInternal = errors.New("Internal server error, please try again later") // ErrInvalidParameters is the standard "Bad Request" error // nolint: stylecheck // this a special error that is displayed to the user as it is. ErrInvalidParameters = errors.New("Some of the request parameters are not correct") // ErrUnmarshalling is the JSON deserialization error // nolint: stylecheck // this a special error that is displayed to the user as it is. ErrUnmarshalling = errors.New("Failed to read JSON from the request body") // ErrForm is the form parsing error // nolint: stylecheck // this a special error that is displayed to the user as it is. ErrForm = errors.New("Failed to parse the submitted form") // ErrNotFound is the standard entity not found error // nolint: stylecheck // this a special error that is displayed to the user as it is. ErrNotFound = errors.New("The requested object was not found") // ErrNotImplemented is intended to be used when stubbing new endpoints // nolint: stylecheck // this a special error that is displayed to the user as it is. ErrNotImplemented = errors.New("Method is not implemented") // ErrUnsupportedMediaType is intended to be used for endpoints that accepts multiple // media types and need to return the standard "415 Unsupported Media Type" response // nolint: stylecheck // this a special error that is displayed to the user as it is. ErrUnsupportedMediaType = errors.New("Unsupported Media Type") )
Functions ¶
func AsUserError ¶
AsUserError wraps the error as a UserError type, this allows automatic handling by the BaseHandler
Types ¶
type APIErrorMessenger ¶
type APIErrorMessenger interface { GetType() ErrorType GetMessage() string // Scrubbed returns a copy of the instance with the message // replaced the cleaned value Scrubbed(string) APIErrorMessenger }
APIErrorMessenger represents an error message
type ErrorResponse ¶
type ErrorResponse struct { // Errors is a list of errors Errors []APIErrorMessenger `json:"errors"` }
ErrorResponse is a generic API error response body
func ValidationErrorsToFieldErrorResponse ¶
func ValidationErrorsToFieldErrorResponse(errs map[string]error) (resp ErrorResponse)
ValidationErrorsToFieldErrorResponse converts validation errors to the format that is served by HTTP handlers
type FieldError ¶
type FieldError struct { GeneralError // Key of the validated field Key string `json:"key"` }
FieldError represents a validation error
func (FieldError) GetKey ¶
func (e FieldError) GetKey() string
func (FieldError) GetMessage ¶
func (e FieldError) GetMessage() string
func (FieldError) GetType ¶
func (e FieldError) GetType() ErrorType
func (FieldError) Scrubbed ¶
func (e FieldError) Scrubbed(_ string) APIErrorMessenger
Scrubbed implemented the APIErrorMessanger, the scrubbing is a noop because FieldError is safe for users by default.
type FieldErrorResponse
deprecated
type FieldErrorResponse struct { // Errors is a list of errors Errors []FieldError `json:"errors"` }
FieldErrorResponse - Error message that contains detailed information about certain parameters being incorrect
Deprecated: replaced with the more generic ErrorResponse
type GeneralError ¶
type GeneralError struct { // Type of the error Type ErrorType `json:"type"` // Message of the validation error Message string `json:"message"` }
GeneralError represents a system error exposed to the user
func (GeneralError) GetMessage ¶
func (e GeneralError) GetMessage() string
func (GeneralError) GetType ¶
func (e GeneralError) GetType() ErrorType
func (GeneralError) Scrubbed ¶
func (e GeneralError) Scrubbed(message string) APIErrorMessenger
Scrubbed implemented the APIErrorMessanger, the scrubbing is replaces the message with the given message value.
type GeneralErrorResponse
deprecated
type GeneralErrorResponse struct { // Errors is a list of errors Errors []GeneralError `json:"errors"` }
GeneralErrorResponse - General error response that usually has a very generic message
Deprecated: replaced with the more generic ErrorResponse
type UserError ¶
type UserError struct {
// contains filtered or unexported fields
}
UserError is an error wrapper that represents a GeneralError caused by some user data or request. The error message is considered safe to show to end users. The HTTP handler can recognize this error type and automatically parse it into a 400 error code.
type ValidationErrors ¶
type ValidationErrors = validation.Errors
ValidationErrors contains errors organized by validated fields for now it's just an alias to the validation library we use