Documentation ¶
Index ¶
- Constants
- func ErrorHandler(service *goa.Service, verbose bool) goa.Middleware
- func ErrorToJSONAPIError(err error) (app.JSONAPIError, int)
- func ErrorToJSONAPIErrors(err error) (*app.JSONAPIErrors, int)
- func JSONErrorResponse(x InternalServerError, err error) error
- type BadRequest
- type Conflict
- type Forbidden
- type InternalServerError
- type NotFound
- type Unauthorized
Constants ¶
const ( ErrorCodeNotFound = "not_found" ErrorCodeBadParameter = "bad_parameter" ErrorCodeVersionConflict = "version_conflict" ErrorCodeUnknownError = "unknown_error" ErrorCodeConversionError = "conversion_error" ErrorCodeInternalError = "internal_error" ErrorCodeForbiddenError = "forbidden_error" ErrorCodeJWTSecurityError = "jwt_security_error" )
const (
// Media type for errors returned by the JSON API error handler middleware
ErrorMediaIdentifier = "application/vnd.api+json"
)
Variables ¶
This section is empty.
Functions ¶
func ErrorHandler ¶
func ErrorHandler(service *goa.Service, verbose bool) goa.Middleware
ErrorHandler turns a Go error into an JSONAPI HTTP response. It should be placed in the middleware chain below the logger middleware so the logger properly logs the HTTP response. ErrorHandler understands instances of goa.ServiceError and returns the status and response body embodied in them, it turns other Go error types into a 500 internal error response. If verbose is false the details of internal errors is not included in HTTP responses. If you use github.com/pkg/errors then wrapping the error will allow a trace to be printed to the logs
func ErrorToJSONAPIError ¶
func ErrorToJSONAPIError(err error) (app.JSONAPIError, int)
ErrorToJSONAPIError returns the JSONAPI representation of an error and the HTTP status code that will be associated with it. This function knows about the models package and the errors from there as well as goa error classes.
func ErrorToJSONAPIErrors ¶
func ErrorToJSONAPIErrors(err error) (*app.JSONAPIErrors, int)
ErrorToJSONAPIErrors is a convenience function if you just want to return one error from the models package as a JSONAPI errors array.
func JSONErrorResponse ¶
func JSONErrorResponse(x InternalServerError, err error) error
JSONErrorResponse auto maps the provided error to the correct response type If all else fails, InternalServerError is returned
Types ¶
type BadRequest ¶
type BadRequest interface {
BadRequest(*app.JSONAPIErrors) error
}
BadRequest represent a Context that can return a BadRequest HTTP status
type Conflict ¶
type Conflict interface {
Conflict(*app.JSONAPIErrors) error
}
Conflict represent a Context that can return a Conflict HTTP status
type Forbidden ¶
type Forbidden interface {
Forbidden(*app.JSONAPIErrors) error
}
Forbidden represent a Context that can return a Unauthorized HTTP status
type InternalServerError ¶
type InternalServerError interface {
InternalServerError(*app.JSONAPIErrors) error
}
InternalServerError represent a Context that can return a InternalServerError HTTP status
type NotFound ¶
type NotFound interface {
NotFound(*app.JSONAPIErrors) error
}
NotFound represent a Context that can return a NotFound HTTP status
type Unauthorized ¶
type Unauthorized interface {
}Unauthorized represent a Context that can return a Unauthorized HTTP status