Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cause ¶
Cause returns the underlying cause of the error, if possible. See https://godoc.org/github.com/pkg/errors#Cause for further details.
func Errorf ¶
Errorf formats according to a format specifier and returns the string as a value that satisfies error. See https://godoc.org/github.com/pkg/errors#Errorf for further details
func LoadMessages ¶
LoadMessages reads a YAML file containing error templates.
func New ¶
New returns an error with the supplied message. See https://godoc.org/github.com/pkg/errors#New for further details
func Wrap ¶
Wrap returns an error annotating err with message. If err is nil, Wrap returns nil. See https://godoc.org/github.com/pkg/errors#Wrap for more details.
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.
type Params ¶
type Params map[string]interface{}
Params is used to replace placeholders in an error template with the corresponding values.
type StackTracer ¶
type StackTracer interface {
StackTrace() errors.StackTrace
}
StackTracer represents a type (usually an error) that can provide a stack trace.