ot-friendly-errors-boom

2.0.1 • Public • Published

ot-friendly-errors-boom

Build Status NPM version Dependencies

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

Readme

Keywords

Package Sidebar

Install

npm i ot-friendly-errors-boom

Weekly Downloads

0

Version

2.0.1

License

MIT

Last publish

Collaborators

  • acolchado
  • arnoldzokas
  • matteofigus
  • ryantomlinson
  • andyroyle
  • stevejhiggs