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.19 to 1.0.20

2

package.json
{
"name": "@azteam/error",
"version": "1.0.19",
"version": "1.0.20",
"description": "",

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

module.exports = Object.freeze({
CORS: 'CORS',
NOT_FOUND: 'NOT_FOUND',

@@ -3,0 +4,0 @@ UNKNOWN: 'UNKNOWN',

const {NOT_FOUND, NOT_NULL, UNIQUE, UNKNOWN} = require('./code');
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});
}
function errorCatch(e) {
let status = 400;
let errors = [];
const errors = [];

@@ -30,3 +21,3 @@ if (e.name !== undefined) {

} else if (e.name === 'SequelizeValidationError') {
for (let item of e.errors) {
for (const item of e.errors) {
if (item.message.includes('cannot be null')) {

@@ -75,2 +66,11 @@ item.message = NOT_NULL;

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 = {

@@ -77,0 +77,0 @@ httpErrorHandler,

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