ErrorEx
'Extensible Error Class' implementation and predefined additional error types for javascript.
Installation
$ npm install errorex --save
Usage
var ErrorEx RangeError = ; var error = 'Value out of range' ;console; // Value out of rangeconsole; // trueconsole; // trueconsole; // RangeError: Value out of rangeconsole; // 1console; // 5console; // Prints stack trace
Extending custom error classes in ES6
{ super...args; thismyproperty = 1000; } { this; } throw 'My message %d' 10;
Extending custom error classes in ES5
{ ErrorEx; thismyproperty = 1000;}MyErrorprototype = Object;MyErrorprototypeconstructor = MyError;MyErrorprototype { this;}; throw 'My message %d' 10;
Predefined error classes
-
ErrorEx: Base error class
-
ArgumentError: Extending from ErrorEx
-
RangeError: Extending from ErrorEx
-
HttpError: Extending from ErrorEx
-
HttpClientError: Extending from HttpError
-
HttpServerError: Extending from HttpError
Node Compatibility
- node
>= 0.10
;