Documentation ¶
Overview ¶
Package errs provides error codes and error handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BadRequest = New(CodeBadRequest, http.StatusText(http.StatusBadRequest)) Forbidden = New(CodeForbidden, http.StatusText(http.StatusForbidden)) NotFound = New(CodeNotFound, http.StatusText(http.StatusNotFound)) Gone = New(CodeGone, http.StatusText(http.StatusGone)) TooManyRequest = New(CodeTooManyRequests, http.StatusText(http.StatusTooManyRequests)) InternalServerError = New(CodeInternalServerError, http.StatusText(http.StatusInternalServerError)) NotImplemented = New(CodeNotImplemented, http.StatusText(http.StatusNotImplemented)) )
Common errors.
Functions ¶
func ResponseError ¶
ResponseError returns an error response.
Types ¶
type Code ¶
type Code string
Code represents an error code.
type Error ¶
type Error struct { // Code is the error code. Code Code `json:"code"` // Message is the error message. Message string `json:"message"` // Info is additional information about the error. Info map[string]interface{} `json:"info,omitempty"` // Timestamp is the time when the error occurred. Timestamp time.Time `json:"timestamp"` }
Error represents an error.
func InvalidStructError ¶
InvalidStructError returns a new error for an invalid struct.
func (*Error) HTTPStatusCode ¶
HTTPStatusCode returns the HTTP status code for the error.
Click to show internal directories.
Click to hide internal directories.