node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org »

ot-friendly-errors-boom

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