Name: boom-clone
Owner: TABLEFLIP
Description: Like `Boom.wrap`, but returns a cloned boomified error...because `Boom.wrap` mutates your error object.
Created: 2017-05-30 12:51:17.0
Updated: 2017-05-30 12:52:38.0
Pushed: 2017-05-31 08:57:24.0
Homepage: null
Size: 20
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Like Boom.wrap
, but returns a cloned boomified error…because Boom.wrap
mutates your error object.
Boom = require('boom')
boomClone = require('boom-clone')
Assert = require('assert')
oomify a basic error, without mutating:
basicErr = new Error('Boom!')
ame API as Boom.wrap
err = boomClone(basicErr, 500, 'A bad')
rt.ok(err !== basicErr) // Not same error object
rt.ok(basicErr.isBoom !== true) // Original NOT boomified
rt.ok(err.isBoom) // Cloned has been boomified
rt.equal(err.output.statusCode, 500) // Status set
rt.equal(err.message, 'A bad') // Message set
lone a boom:
boomErr = Boom.create(500)
err = boomClone(boomErr)
rt.ok(err !== basicErr) // Not same error object
rt.ok(err.isBoom) // still a boom though
boomClone(error, [statusCode], [message])
Return a cloned boomified error object.
error
A JavaScript Error object[statusCode]
Optional HTTP status code[message]
Optional error messageNOTE: statusCode
and message
are invalid params(!) if passed along with an already boomified error
.
A (?°?°???TABLEFLIP side project.