hoek-boom

1.3.0 • Public • Published

hoek-boom Build Status Dependency Status devDependency Status

hoek Logo

boom Logo

+ 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(=== b, 'a should equal b', 'expectationFailed');  // ABORT: a should equal b, throw boom error
 
// other uses ...
HoekBoom.assertBoom(); // throws Error
HoekBoom.assertBoom(=== b); // throws Error
HoekBoom.assertBoom(=== b, new Error('example')); // throws given error object
HoekBoom.assertBoom(=== b, 'badRequest'); // throws Boom.badRequest()
HoekBoom.assertBoom(=== b, 'some message'); // throws Error('some message')
HoekBoom.assertBoom(=== b, 'some', 'message', new Error('here'), 'for all', {test: 'lolz'});  // throws Error('some message here for all ' + JSON.stringify({test: 'lolz'}))
HoekBoom.assertBoom(=== b, 'some', 'message'); // throws Error('some message')
HoekBoom.assertBoom(=== b, 'check the docs', 'badRequest'); // throws Boom.badRequest('check the docs')
HoekBoom.assertBoom(=== b, 'check the docs', {username: 'johnsmith'}, 'badRequest'); // throws Boom.badRequest('check the docs', {username: 'johnsmith'})
HoekBoom.assertBoom(=== 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'));

Package Sidebar

Install

npm i hoek-boom

Weekly Downloads

2

Version

1.3.0

License

BSD

Last publish

Collaborators

  • mrlannigan