0.1.5 • Published 10 years ago

node-error v0.1.5

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

Error

Error is a library of extendable custom errors for node.js.

Installation

npm node-error --save

Usage

Errors in the library can be instantiated directly

var
	LoggableError = require('node-error').LoggableError;

throw new LoggableError('message');

or extended using .extend(name, [attributes]):

var
	LoggableError = require('node-error').LoggableError;

var
	attributes = function () {
		return {
			memoryUsage: process.memoryUsage()
		};
	},
	CustomError = LoggableError.extend('CustomError', attributes);

The attributes argument to the extend method is optional. It can be of type object or function. The function executes upon error instantiation and it should return an object.

var
	error = new CustomError('message');

console.log(error.attributes);

Errors

ExtendableError

ExtendableError is the base error to extend using .extend method.

LoggableError

LoggableError is an error having the stack property enumerable.

ProxiedError

var
	ProxiedError = require('node-error').ProxiedError;

var
	error = new ProxiedError(new Error());
0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago