krrs-error-code-parser

1.1.4 • Public • Published

error-code-parser

npm version

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

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i krrs-error-code-parser

    Weekly Downloads

    0

    Version

    1.1.4

    License

    ISC

    Unpacked Size

    2.74 kB

    Total Files

    3

    Last publish

    Collaborators

    • rishikesh.shetty