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

quantal-errors

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quantal-errors - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

32

lib/express-error-middleware.js

@@ -1,4 +0,1 @@

/**
* Created by dman on 03/07/2017.
*/
'use strict'

@@ -8,4 +5,33 @@ const utils = require('./utils')

/**
* Maps an err to boom errors
// will map custom errors to boom errors
// This should be the last middleware in the chain
/**
* For example
*
* customErrors = {
* MyCustomError: createError('MyCustomError')
* }
* customMappings = {
* badRequest: ['MyCustomError']
* }
* @param customErrors
* @param customMappings
* @returns {function(*=, *, *, *)}
*/
module.exports = (customErrors, customMappings) => {
return (err, req, res, next) => {
// will map custom errors to boom errors
// This should be the last middleware in the chain
/**
* For example
*
* customErrors = {
* MyCustomError: createError('MyCustomError')
* }
* customMappings = {
* badRequest: ['MyCustomError']
* }
*/
const boomErr = utils.toBoom(err, customErrors, customMappings)

@@ -12,0 +38,0 @@ res.status(boomErr.output.statusCode).json(_.omit(boomErr.output.payload, ['params']))

@@ -94,5 +94,14 @@ 'use strict'

* Translates application error to boom error based defined mapping or default mapping
* For example
*
* customErrors = {
* MyCustomError: createError('MyCustomError')
* }
* customMapping = {
* badRequest: ['MyCustomError']
* }
*
* @param {Error} err Error to convert
* @param {object} customErrors
* @param {object} customMapping
* @param {object} customErrors - hash / object that of custom errors
* @param {object} customMapping - mappings between custome errors and boom errors
* @return {Error} Boom error

@@ -99,0 +108,0 @@ */

2

package.json
{
"name": "quantal-errors",
"version": "0.0.10",
"version": "0.0.11",
"description": "Common errors and their utils",

@@ -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