🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

boom-clone

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boom-clone

Boom.wrap that returns a cloned boomed error

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

boom-clone Build Status dependencies Status

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

Example

var Boom = require('boom')
var boomClone = require('boom-clone')
var Assert = require('assert')

// Boomify a basic error, without mutating:

var basicErr = new Error('Boom!')
// Same API as Boom.wrap
var err = boomClone(basicErr, 500, 'A bad')

Assert.ok(err !== basicErr) // Not same error object
Assert.ok(basicErr.isBoom !== true) // Original NOT boomified
Assert.ok(err.isBoom) // Cloned has been boomified
Assert.equal(err.output.statusCode, 500) // Status set
Assert.equal(err.message, 'A bad') // Message set

// Clone a boom:

var boomErr = Boom.create(500)
var err = boomClone(boomErr)

Assert.ok(err !== basicErr) // Not same error object
Assert.ok(err.isBoom) // still a boom though

API

boomClone(error, [statusCode], [message])

Return a cloned boomified error object.

  • error A JavaScript Error object
  • [statusCode] Optional HTTP status code
  • [message] Optional error message

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

A (╯°□°)╯︵TABLEFLIP side project.

Keywords

boom

FAQs

Package last updated on 31 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts