Comparing version 5.1.0 to 5.2.0
@@ -73,2 +73,22 @@ 'use strict'; | ||
exports.boomify = function (error, options) { | ||
Hoek.assert(error instanceof Error, 'Cannot wrap non-Error object'); | ||
options = options || {}; | ||
if (!error.isBoom) { | ||
return internals.initialize(error, options.statusCode || 500, options.message); | ||
} | ||
if (options.override === false || // Defaults to true | ||
(!options.statusCode && !options.message)) { | ||
return error; | ||
} | ||
return internals.initialize(error, options.statusCode || error.output.statusCode, options.message); | ||
}; | ||
exports.wrap = function (error, statusCode, message) { | ||
@@ -75,0 +95,0 @@ |
{ | ||
"name": "boom", | ||
"description": "HTTP-friendly error objects", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"repository": "git://github.com/hapijs/boom", | ||
@@ -19,3 +19,3 @@ "main": "lib/index.js", | ||
"code": "4.x.x", | ||
"lab": "13.x.x", | ||
"lab": "14.x.x", | ||
"markdown-toc": "0.12.x" | ||
@@ -22,0 +22,0 @@ }, |
@@ -14,2 +14,3 @@ ![boom Logo](https://raw.github.com/hapijs/boom/master/images/boom.png) | ||
- [Helper Methods](#helper-methods) | ||
- [`boomify(error, [options])`](#boomifyerror-options) | ||
- [`wrap(error, [statusCode], [message])`](#wraperror-statuscode-message) | ||
@@ -77,4 +78,26 @@ - [`create(statusCode, [message], [data])`](#createstatuscode-message-data) | ||
### `boomify(error, [options])` | ||
Decorates an error with the **boom** properties where: | ||
- `error` - the `Error` object to decorate. | ||
- `options` - optional object with the following optional settings: | ||
- `statusCode` - the HTTP status code. Defaults to `500` if no status code is already set. | ||
- `message` - error message string. If the error already has a message, the provided `message` is added as a prefix. | ||
Defaults to no message. | ||
- `override` - if `false`, the `error` provided is a **boom** object, and a `statusCode` or `message` are provided, | ||
the values are ignored. Defaults to `true` (apply the provided `statusCode` and `message` options to the error | ||
regardless of its type, `Error` or **boom** object). | ||
Note: This method replaces the [`wrap()`](#wraperror-statuscode-message) and changes the default behavior to override | ||
existing **boom** objects with the provided status code and message. | ||
```js | ||
var error = new Error('Unexpected input'); | ||
Boom.boomify(error, { statusCode: 400 }); | ||
``` | ||
### `wrap(error, [statusCode], [message])` | ||
Note: This method is deprecated. | ||
Decorates an error with the **boom** properties where: | ||
@@ -81,0 +104,0 @@ - `error` - the error object to wrap. If `error` is already a **boom** object, returns back the same object. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34429
300
785