Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = &ErrResponse{ HTTPStatusCode: http.StatusNotFound, StatusText: "Resource not found", }
ErrNotFound is the wrapped error for not found resources
View Source
var ErrNotImplemented = &ErrResponse{ HTTPStatusCode: http.StatusNotImplemented, StatusText: "Method not implemented", }
ErrNotImplemented is the wrapped error for not implemented methods
Functions ¶
This section is empty.
Types ¶
type ErrResponse ¶
type ErrResponse struct {
Err error `json:"-"` // low-level runtime error
HTTPStatusCode int `json:"-"` // http response status code
StatusText string `json:"status"` // user-level status message
ErrorText string `json:"error,omitempty"` // application-level error
}
ErrResponse renderer type for handling all sorts of errors.
In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.
func ErrBadRequest ¶
func ErrBadRequest(err error) *ErrResponse
ErrBadRequest when supplied data is not correct
func ErrForbidden ¶
func ErrForbidden(err error) *ErrResponse
ErrForbidden when there is a server side issue
func ErrInternal ¶
func ErrInternal(err error) *ErrResponse
ErrInternal when there is a server side issue
func ErrUnauthorized ¶
func ErrUnauthorized(err error) *ErrResponse
ErrUnauthorized when there is a server side issue
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
Render rendering the error
Click to show internal directories.
Click to hide internal directories.