New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

project-error

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

project-error

Customized error class module for projects/microservices. Throw error objects within a JavaScript Error class while preserving the stack.

latest
Source
npmnpm
Version
2.0.3
Version published
Weekly downloads
3
-76.92%
Maintainers
1
Weekly downloads
 
Created
Source

ProjectError

CircleCI codecov Codacy Badge npm npm David David license

codecov

Customized error class module for project/microservices. Throw error enum objects within a JavaScript Error class preserving the stack.

Installation

npm install --save project-error

Usage

  • Pass any object containing into the first argument of ProjectError:
var ProjectError = require('project-error');

throw new ProjectError({
    code: 4010,
    statusCode: 400,
    message: 'Bad Request'
});
  • Pass additional error details as either a string or an array of strings:
var ProjectError = require('project-error');

var errorObj = {
    code: 4010,
    statusCode: 400,
    message: 'Bad Request'
};
var errorDetail = 'This is a one-liner error detail';
throw new ProjectError(errorObj, errorDetail);
var ProjectError = require('project-error');

var errorObj = {
    code: 4010,
    statusCode: 400,
    message: 'Bad Request'
};
var errorDetails = [
    'This is multiple lines of error details',
    'This is multiple lines of error details',
    'This is multiple lines of error details'
];
throw new ProjectError(errorObj, errorDetails);
  • Pass a standard Error object and preserve the stack:
var errorObj = {
    code: 4010,
    statusCode: 400,
    message: 'Bad Request'
};
var errorDetail = 'This is a one-liner error detail';
var error = new Error('Fail!');
throw new ProjectError(errorObj, errorDetail, error);

Keywords

custom-error

FAQs

Package last updated on 04 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts