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

error-engine

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-engine

This module provides a base class for easy Node error message templating. Use Node's native module "util" to inherit from the ErrorEngine base class. See below for an example, and see the `tests.js` file for more examples.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

error-engine

This module provides a base class for easy Node error message templating. Use Node's native module "util" to inherit from the ErrorEngine base class. See below for an example, and see the tests.js file for more examples.

Use

ErrorEngine(options, dictionary, key, params)

  • options: The options object
    • options.auto_template: Indicate's whether or not the object should be templated using lodash's template function (optional)
  • dictionary: The dictionary of error messages mapping keys to values.
  • key: The key to use to construct the error message.
  • params: The parameters used when compiling an error message. (optional)

Example

var _ = require("lodash");
var ErrorEngine = require("error-engine");

var dictionary = {
    "my_error_type": "This is my error message",
    "my_super_error_type": _.template("Wow! This is <% adjective %>!")
};

function MyNewError(code, key, params) {
    ErrorEngine.call(this, {}, dictionary, key, params);

    this.code = code;
}
util.inherits(MyNewError, ErrorEngine);

var err1 = new MyNewError(42, "my_error_type");
var err2 = new MyNewError(73, "my_super_error_type", {
    "adjective": "awesome"
});

Keywords

error

FAQs

Package last updated on 01 Sep 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