waterline-to-boom
v1.0.0
Published
Transform waterline errors to Boom errors for general hapiness.
Downloads
14
Maintainers
Readme
waterline-to-boom
Transform waterline errors to Boom errors
API
WL2Boom(err, [resourceName], [allowed])
Turns standard WLError
, WLUsageError
, and WLValidationError
Waterline errors into proper Boom errors for use in hapi error handlers. Best used with dogwater.
WLError
gets wrapped by Boom (status code set in error'scode
property, error message set in error'sreason
property).WLUsageError
becomes aBoom.badImplementation
(500).WLValidationError
includes validation errors in aBoom.badData
(422).- All others become a
Boom.badImplementation
(500).
Arguments
err
- the Waterline errorresourceName
- (optional) the resource name (often a Waterline collection identity). This is used when buildingWLValidationError
into a Boom error.allowed
- (optional) an array of allowed attributes. Only validation errors on these attributes will be mentioned in the resulting Boom errors resulting fromWLValidationError
s. If not provided, all attributes are fair-game for mentioning.