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

@azteam/error

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azteam/error - npm Package Compare versions

Comparing version 1.0.21 to 1.0.22

2

package.json
{
"name": "@azteam/error",
"version": "1.0.21",
"version": "1.0.22",
"description": "",

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

@@ -1,2 +0,2 @@

const {NOT_FOUND, NOT_NULL, UNIQUE, UNKNOWN} = require('./code');
const {NOT_FOUND, VALIDATE, UNIQUE, UNKNOWN} = require('./code');

@@ -8,32 +8,8 @@ function errorCatch(e) {

if (e.name !== undefined) {
if (e.name === 'SequelizeValidationError' || e.name === 'SequelizeUniqueConstraintError') {
if (e.name === 'SequelizeUniqueConstraintError') {
for (let item of e.errors) {
errors.push({
code: UNIQUE,
message: UNIQUE,
data: {
field: item.path.replace('UNI_', ''),
value: item.value,
},
});
}
} else if (e.name === 'SequelizeValidationError') {
for (const item of e.errors) {
if (item.message.includes('cannot be null')) {
item.message = NOT_NULL;
}
errors.push({
code: item.message,
message: item.message,
data: {
field: item.path,
value: item.value,
},
});
}
}
} else if (e.name === 'ErrorException') {
if (e.name === 'ErrorException') {
let fields = [];
if (e.code === NOT_FOUND) {
status = 404;
} else if (e.code === VALIDATE) {
fields = e.errors.map((obj) => obj.field);
}

@@ -44,2 +20,3 @@ errors.push({

data: e.errors,
fields: fields.join(','),
});

@@ -57,2 +34,3 @@ } else if (e.name === 'MulterError') {

data: e.keyValue,
fields: Object.keys(e.keyValue).join(','),
});

@@ -76,14 +54,4 @@ }

function httpErrorHandler(e, req, res, next) {
const error = errorCatch(e);
if (process.env.NODE_ENV === 'development') {
console.log(error.errors);
}
return res.status(error.status).json({success: false, errors: error.errors});
}
module.exports = {
httpErrorHandler,
errorCatch,
};
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