Documentation ¶
Index ¶
- func Equals(a error, b error) bool
- type Error
- func InternalServerError(err error) *Error
- func New(httpStatus int, displayMsg string, err error) *Error
- func NotFound(res string, err error) *Error
- func ParameterMissing(param string, err error) *Error
- func PermissionDenied(action, subject string, err error) *Error
- func ValueRequired(param string) *Error
- func ValueTooLong(param string, nchars int) *Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
type Error struct { DisplayMsg string `json:"display_message"` HTTPStatus int `json:"status"` Err error `json:"-"` }
Error enriches the original go error type with DisplayMsg the description for the displaying message HTTPStatus the HTTP status code Err the internal error it should not be shown to the user
func InternalServerError ¶
InternalServerError returns a internal server error message with code 500. Display message: "An internal server error occured."
func NotFound ¶
NotFound returns a not found message with code 404. The following display message is returned: "The [res] was not found."
func ParameterMissing ¶
ParameterMissing returns a parameter missing message with code 422. Display message: "The parameter [param] is invalid."
func PermissionDenied ¶
PermissionDenied returns a permission denied message with code 403. The following display message is returned: "You are not allowed to [action] the [subject]."
func ValueRequired ¶
ValueRequired returns a value required message with code 422. Display message: "Please fill out the field [param]."
func ValueTooLong ¶
ValueTooLong returns the following display message with code 422. Display message: "The value of [param] is too long. Maximum [nchars] characters are allowed."