ot-friendly-errors-boom
v2.0.1
Published
snippet to wrap errors in a boom object for hapi
Downloads
2
Readme
Wraps the creation of boom objects from either js Error object, or a custom error { code: 409, message: "conflict", body: { foo: "bar" } }
Useful for when you want to handle failure conditions (e.g. 4xx codes) as an Error without having to crowbar your data into a javascript Error object.
installation
npm install ot-friendly-errors-boom
usage:
var friendlyErrors = require("ot-friendly-errors-boom");
var err = new Error("shit broke");
var customErr = { code: 418, message: "I'm a teapot" };
reply(friendlyErrors.transform(err));
// produces a boom object with responseCode 500
reply(friendlyErrors.transform(customErr));
// produces a boom object with responseCode 418
Dependencies:
- boom