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

error-handler-e2

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-handler-e2 - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

63

index.js

@@ -1,20 +0,55 @@

const error = (message, status) => {
let error_type;
if (status >= 400 && status < 500) {
error_type = "Client Error.";
} else if(status >= 500 && status < 600){
error_type = " Server Error.";
} else{
error_type = `${status}, it should not be a error status code`;
/**
* @author Milad E. Fahmy
* @param {String} colorName
* @description colorName cane be on of the following Bright, Dim, Underscore,
* FgBlack, FgRed, FgGreen, FgYellow, FgBlue, FgMagenta, FgCyan, FgWhite
*/
const getColor = (colorName) => {
const colors = {
Bright: "\x1b[1m",
Dim: "\x1b[2m",
Underscore: "\x1b[4m",
FgBlack: "\x1b[30m",
FgRed: "\x1b[31m",
FgGreen: "\x1b[32m",
FgYellow: "\x1b[33m",
FgBlue: "\x1b[34m",
FgMagenta: "\x1b[35m",
FgCyan: "\x1b[36m",
FgWhite: "\x1b[37m",
}
return colors[colorName];
}
/**
* @author Milad E. Fahmy
* @param {Object} error
* @description this a function to custom log errors
*/
const logErrors = ({ type, file, path, message, status, ...restArgs }) => {
return {
message,
status,
error_type,
};
console.group(getColor("FgRed"), `Error: ${type.toUpperCase()}`)
console.log(getColor("FgGreen"), "*** Start Logging Error ***\n");
console.log(getColor("FgBlue"), `The error in File : ${file}`);
console.log(getColor("FgBlue"), `The error with status code : ${status}`);
console.log(getColor("FgBlue"), `The error in path : ${path}`);
console.log(getColor("FgBlue"), `Custom message :${message}\n`);
let restErrors = Object.keys(restArgs)
for (let index = 0; index < restErrors.length; index++) {
const key = restErrors[index];
console.group(getColor("FgCyan"), `Related Errors: `);
console.log(getColor("FgYellow"), `${key.toUpperCase()} => ${restArgs[key]}`);
}
console.groupEnd();
console.log("\n")
console.log(getColor("FgGreen"), "*** End Logging Error ***");
console.groupEnd();
}
module.exports = {
error
getColor,
logErrors
}
{
"name": "error-handler-e2",
"version": "1.1.1",
"version": "2.0.0",
"description": "This is handle error package",

@@ -8,3 +8,18 @@ "main": "index.js",

"author": "Milad E. Fahmy",
"license": "ISC"
"license": "ISC",
"repository": {
"type": "git",
"url": "git+https://github.com/miladezzat/error-handler-e2.git"
},
"bugs": {
"url": "https://github.com/miladezzat/error-handler-e2/issues"
},
"homepage": "https://github.com/miladezzat/error-handler-e2#readme",
"keywords": [
"Errors",
"error",
"error-handler",
"expressjs",
"nodejs"
]
}
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