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

stderror

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stderror

Extendable error class derived from native Error object.

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

stderror

Extendable error class derived from native Error object.

Installation

$ npm install stderror

Usage

var StandardError = require("stderror");

throw new StandardError();
throw new StandardError("My custom error.");
throw new StandardError({code: 1000, message: "My custom error."});

//-- also works without using new
throw StandardError("My custom error.");

Methods

extend(name)

extend(options)

Returns the derived error object based on the given argument.

var UnknownError = StandardError.extend("UnknownError");
var SystemError = StandardError.extend({
  code: 2000,
  name: "SystemError",
  message: "System error."
});

var RecordNotFound = StandardError.extend("RecordNotFound");
var UserNotFound = RecordNotFound.extend({
  name: "UserNotFound",
  message: "User not found."
});

define(name)

define(options)

A form of namespacing errors by encapsulating them in a parent error object.

var Exception = StandardError.extend("Exception");
Exception.define("InvalidArgument");
Exception.define({
  code: 1000,
  name: "InvalidPassword",
  message: "Invalid password.",
  parent: "InvalidArgument"
});

throw new Exception.InvalidArgument();
throw new Exception.InvalidPassword();

Keywords

error

FAQs

Package last updated on 09 Dec 2015

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