Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@c8/errors

Package Overview
Dependencies
Maintainers
6
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@c8/errors - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

3

lib/boom-mapping.js

@@ -9,4 +9,1 @@ module.exports = {

}
// NotUpdatedError
// NotRemovedError

7

lib/errors.js

@@ -7,11 +7,8 @@ 'use strict'

SizeError: createError('SizeError'),
TypeError: createError('TypeError'),
ReadError: createError('ReadError'),
PermissionDeniedError: createError('PermissionDeniedError'),
NotFoundError: createError('NotFoundError'),
NotUpdatedError: createError('NotUpdatedError'),
NotRemovedError: createError('NotRemovedError'),
InvalidInputError: createError('InvalidInputError'),
TimeoutError: createError('TimeoutError'),
AlreadyExistsError: createError('AlreadyExistsError')
AlreadyExistsError: createError('AlreadyExistsError'),
NotImplementedError: createError('AlreadyExistsError')
}

@@ -6,3 +6,3 @@ 'use strict'

const Errors = require('./errors')
const mapping = require('./boom-mapping')
const defaultMapping = require('./boom-mapping')

@@ -32,2 +32,22 @@ /**

/**
* Merge two error mappings
* @param {object} m1
* @param {object} m2
* @returns {object} mergedMappings
*/
const mergeMappings = (m1, m2) => {
const m1Keys = Object.keys(m1)
for (let m1Key of m1Keys) {
if (m2[m1Key]) {
m2[m1Key] = _.union(m2[m1Key], m1[m1Key])
} else {
m2[m1Key] = m1[m1Key]
}
}
return m2
}
module.exports = {

@@ -41,2 +61,4 @@ /**

toBoom: (err, customErrors, customMapping) => {
let mapping = defaultMapping
// add custom errors, if any. Overwrites default custom errors if duplicate key is specified

@@ -46,5 +68,5 @@ if (typeof customErrors === 'object') _.assignIn(Errors, customErrors)

// add custom mapping, if any. Overwrites default mapping if duplicate keys are specified
if (typeof customMapping === 'object') _.assignIn(mapping, customMapping)
if (typeof customMapping === 'object') mapping = mergeMappings(defaultMapping, customMapping)
const origErr = _.deepClone(err)
const origErr = _.cloneDeep(err)
const errParams = _.omit(err, 'message')

@@ -55,3 +77,3 @@

for (let customErr of mapping[boomErr]) {
if (origErr instanceof Errors[customErr]) {
if (Errors[customErr] && origErr instanceof Errors[customErr]) {
return Boom[boomErr](origErr.message, errParams)

@@ -58,0 +80,0 @@ }

{
"name": "@c8/errors",
"version": "0.1.0",
"version": "0.1.1",
"description": "Common errors and their utils used by C8 management",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc