hoek-boom
v1.3.0
Published
Extending node utilities shared amongst the extended hapi universe with some boom sprinkles
Downloads
8
Readme
hoek-boom
+ a few additions
Introduction
This library extends Hoek and exposes Boom.
Additional Features
On top of the already exposed Hoek module API.
assertBoom( condition, message, errorName )
var a = 1, b = 2;
HoekBoom.assertBoom(a === b, 'a should equal b', 'expectationFailed'); // ABORT: a should equal b, throw boom error
// other uses ...
HoekBoom.assertBoom(); // throws Error
HoekBoom.assertBoom(a === b); // throws Error
HoekBoom.assertBoom(a === b, new Error('example')); // throws given error object
HoekBoom.assertBoom(a === b, 'badRequest'); // throws Boom.badRequest()
HoekBoom.assertBoom(a === b, 'some message'); // throws Error('some message')
HoekBoom.assertBoom(a === b, 'some', 'message', new Error('here'), 'for all', {test: 'lolz'}); // throws Error('some message here for all ' + JSON.stringify({test: 'lolz'}))
HoekBoom.assertBoom(a === b, 'some', 'message'); // throws Error('some message')
HoekBoom.assertBoom(a === b, 'check the docs', 'badRequest'); // throws Boom.badRequest('check the docs')
HoekBoom.assertBoom(a === b, 'check the docs', {username: 'johnsmith'}, 'badRequest'); // throws Boom.badRequest('check the docs', {username: 'johnsmith'})
HoekBoom.assertBoom(a === b, 'invalid password', 'sample', {username: 'johnsmith'}, 'unauthorized'); // throws Boom.unauthorized('invalid password', 'sample', {username: 'johnsmith'})
Boom
var Boom = HoekBoom.Boom;
reply(Boom.notFound('stuff wasn\'t found here'));