krrs-error-code-parser
v1.1.4
Published
Error handler for handling basic errors in a certain format.
Downloads
3
Maintainers
Readme
error-code-parser
A utility npm package that parses error messages and extracts relevant information to generate a structured error object.
Installation
npm install krrs-error-code-parser
Usage
const errorCodeParser = require('error-code-parser');
const error = new Error('BAD_REQUEST Something not found');
const parsedError = errorCodeParser(error);
console.log(parsedError);
output: {
code: 400,
message: 'Something not found'
}
Supported Error Codes
BAD_REQUEST, BAD_REQUEST_TO_IGNORE = 400 NOT_FOUND = 404 CONFLICT = 422 FORBIDDEN = 403 UNPROCESSABLE = 422 default = 500