create-boom-error
Advanced tools
Comparing version 0.1.0 to 0.2.0
17
index.js
'use strict'; | ||
var Boom = require('boom'); | ||
const Boom = require('@hapi/boom'); | ||
/** | ||
* | ||
* @param {string} name | ||
* @param {number} statusCode | ||
* @param {function | string} message | ||
* @returns {new () => Boom<null>} | ||
*/ | ||
function createBoomError(name, statusCode, message) { | ||
@@ -11,2 +18,3 @@ var exports = this; | ||
this.message = undefined; | ||
if (typeof message === 'string') { | ||
@@ -18,3 +26,7 @@ this.message = message; | ||
Boom.wrap(this, statusCode); | ||
Boom.boomify(this, { statusCode, }); | ||
if (message === undefined) { | ||
Reflect.deleteProperty(this.output.payload, 'message'); | ||
} | ||
} | ||
@@ -31,5 +43,4 @@ | ||
return ErrorCtor; | ||
} | ||
module.exports = createBoomError; |
{ | ||
"name": "create-boom-error", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Simply create sub-classed Boom errors for Hapi applications.", | ||
@@ -29,7 +29,7 @@ "main": "index.js", | ||
"chai": "^2.1.2", | ||
"mocha": "^2.2.1" | ||
"mocha": "^7.1.0" | ||
}, | ||
"dependencies": { | ||
"boom": "^2.6.1" | ||
"@hapi/boom": "^7.4.0" | ||
} | ||
} |
@@ -1,4 +0,3 @@ | ||
# create-boom-error | ||
[![npm version](https://badge.fury.io/js/create-boom-error.svg)](http://badge.fury.io/js/create-boom-error) | ||
[![Build Status](https://travis-ci.org/lob/create-boom-error.svg)](https://travis-ci.org/lob/create-boom-error) | ||
# create-boom-error [![npm version](https://badge.fury.io/js/create-boom-error.svg)](http://badge.fury.io/js/create-boom-error) [![Build Status](https://travis-ci.org/lob/create-boom-error.svg)](https://travis-ci.org/lob/create-boom-error) | ||
A simple Node.js library for easily creating classed Boom errors in Hapi applications. | ||
@@ -8,3 +7,3 @@ | ||
`npm install create-boom-error` | ||
`yarn add create-boom-error` | ||
@@ -68,5 +67,6 @@ # Usage | ||
# TODO | ||
# Development | ||
- [ ] Add to Travis | ||
- [ ] Push to NPM | ||
## Run tests | ||
`yarn test` |
Sorry, the diff of this file is not supported yet
101
7256
+ Added@hapi/boom@^7.4.0
+ Added@hapi/boom@7.4.11(transitive)
+ Added@hapi/hoek@8.5.1(transitive)
- Removedboom@^2.6.1
- Removedboom@2.10.1(transitive)
- Removedhoek@2.16.3(transitive)