tableflip/boom-clone

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

boom-clone Build Status dependencies Status

Like Boom.wrap, but returns a cloned boomified error…because Boom.wrap mutates your error object.

Example
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
API
boomClone(error, [statusCode], [message])

Return a cloned boomified error object.

NOTE: statusCode and message are invalid params(!) if passed along with an already boomified error.


A (?°?°???TABLEFLIP side project.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.