
Error Handler E2
This package will help you to handle errors, and logging errors with nice style for debugging, and you can use handleHttpError middleware
Sponsor This Project
you can support us with a little, but this become more for us.
Getting Start
You need download package in your project and import any function you need
Installing && Using
npm install npm i error-handler-e2
//or
yarn add error-handler-e2
const ErrorHandlerrE2 = require("error-handler-e2");
//or
import ErrorHandlerrE2 from "error-handler-e2";
Examples
Using Functions
- create custom error
const { createCustomError } = require("error-handler-e2").functions;
//params createCustomError({message: String, error: ErrorObj, [options]})
const myError = createCustomError({
message = "Testing Error message",
error = {},
});
- create Http Error
const { createHttpError } = require("error-handler-e2").functions;
//params createHttpError({message: String, statusCode: Number, [options]})
const httpError = createHttpError({
message = "This is message",
statusCode = 404,
})
- Logging Errors
const { createCustomError,createHttpError ,logErrors }
= require("error-handler-e2").functions;
//params createHttpError({message: String, statusCode: Number, [options]})
const httpError = createHttpError({
message = "This is message",
statusCode = 404,
})
//params createCustomError({message: String, error: ErrorObj, [options]})
const myError = createCustomError({
message = "Testing Error message",
error = {},
});
logErrors({
error: httpError,
file: "index.js",
path: `${__dirname}/${__filename}`,
});
logErrors({
error: myError,
file: "index.js",
path: `${__dirname}/${__filename}`,
});
Using Middlewares
const { handleHttpError } = require('error-handler-e2).middlwares;
const { createHttpError } = require('error-handler-e2).functions;
//params createHttpError({message: String, statusCode: Number, [options]})
const httpError = createHttpError({
message = "This is message",
statusCode = 404,
});
//you need throw httpError, when catch error
throw httpError;
//after your routes, using handle error middleware
app.use(handleHttpError());
Authors
Related articles
Encrypt By RSA Algorithm
RSA is a public-key cryptosystem that is widely used for secure data transmission. It is also one of the oldest. The acronym RSA comes from the surnames of Ron Rivest.
De Duplicated
This is package for deleting the duplicated elements in array, there are contain two methods, first method called simpleArray, this method deduplicated the…
Memoz
Memoz is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported, Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.