Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadMessages ¶
LoadMessages reads a YAML file containing error templates.
Types ¶
type APIError ¶
type APIError struct { // Status represents the HTTP status code Status int `json:"-"` // ErrorCode is the code uniquely identifying an error ErrorCode string `json:"error_code"` // Message is the error message that may be displayed to end users Message string `json:"message"` // DeveloperMessage is the error message that is mainly meant for developers DeveloperMessage string `json:"developer_message,omitempty"` // Details specifies the additional error information Details interface{} `json:"details,omitempty"` }
APIError represents an error that can be sent in an error response.
func InternalServerError ¶
InternalServerError creates a new API error representing an internal server error (HTTP 500)
func InvalidData ¶
func InvalidData(errs validation.Errors) *APIError
InvalidData converts a data validation error into an API error (HTTP 400)
func NewHTTPError ¶
NewHTTPError creates a new APIError with the given HTTP status code, error code, and parameters for replacing placeholders in the error template. The param can be nil, indicating there is no need for placeholder replacement.
func Unauthorized ¶
Unauthorized creates a new API error representing an authentication failure (HTTP 401)
func (APIError) StatusCode ¶
StatusCode returns the HTTP status code.
Click to show internal directories.
Click to hide internal directories.