Gathering detailed insights and metrics for error-ex
Gathering detailed insights and metrics for error-ex
Gathering detailed insights and metrics for error-ex
Gathering detailed insights and metrics for error-ex
ex-error
Extendible error wrapper for NodeJS and browser
@npmtuanmap/ex-vel-expedita-impedit
@d3vtool/ex-frame
This library enhances Express.js by providing a more organized structure for web API projects, along with improved control and error handling capabilities.
@teamteanpm2024/et-ex-voluptatum
security holding package
npm install error-ex
Typescript
Module System
Node Version
NPM Version
CoffeeScript (67.7%)
JavaScript (32.3%)
Total Downloads
7,923,302,786
Last Day
7,089,679
Last Week
44,825,747
Last Month
184,580,463
Last Year
1,910,626,020
MIT License
65 Stars
49 Commits
14 Forks
3 Watchers
2 Branches
5 Contributors
Updated on Apr 19, 2025
Latest Version
1.3.2
Package Id
error-ex@1.3.2
Size
3.47 kB
NPM Version
5.6.0
Node Version
9.6.1
Published on
Jun 19, 2018
Cumulative downloads
Total Downloads
Last Day
14.5%
7,089,679
Compared to previous day
Last Week
10.7%
44,825,747
Compared to previous week
Last Month
-1.8%
184,580,463
Compared to previous month
Last Year
15.2%
1,910,626,020
Compared to previous year
1
Easily subclass and customize new Error types
To include in your project:
1var errorEx = require('error-ex');
To create an error message type with a specific name (note, that ErrorFn.name
will not reflect this):
1var JSONError = errorEx('JSONError'); 2 3var err = new JSONError('error'); 4err.name; //-> JSONError 5throw err; //-> JSONError: error
To add a stack line:
1var JSONError = errorEx('JSONError', {fileName: errorEx.line('in %s')}); 2 3var err = new JSONError('error') 4err.fileName = '/a/b/c/foo.json'; 5throw err; //-> (line 2)-> in /a/b/c/foo.json
To append to the error message:
1var JSONError = errorEx('JSONError', {fileName: errorEx.append('in %s')}); 2 3var err = new JSONError('error'); 4err.fileName = '/a/b/c/foo.json'; 5throw err; //-> JSONError: error in /a/b/c/foo.json
errorEx([name], [properties])
Creates a new ErrorEx error type
name
: the name of the new type (appears in the error message upon throw;
defaults to Error.name
)properties
: if supplied, used as a key/value dictionary of properties to
use when building up the stack message. Keys are property names that are
looked up on the error message, and then passed to function values.
line
: if specified and is a function, return value is added as a stack
entry (error-ex will indent for you). Passed the property value given
the key.stack
: if specified and is a function, passed the value of the property
using the key, and the raw stack lines as a second argument. Takes no
return value (but the stack can be modified directly).message
: if specified and is a function, return value is used as new
.message
value upon get. Passed the property value of the property named
by key, and the existing message is passed as the second argument as an
array of lines (suitable for multi-line messages).Returns a constructor (Function) that can be used just like the regular Error constructor.
1var errorEx = require('error-ex'); 2 3var BasicError = errorEx(); 4 5var NamedError = errorEx('NamedError'); 6 7// -- 8 9var AdvancedError = errorEx('AdvancedError', { 10 foo: { 11 line: function (value, stack) { 12 if (value) { 13 return 'bar ' + value; 14 } 15 return null; 16 } 17 } 18} 19 20var err = new AdvancedError('hello, world'); 21err.foo = 'baz'; 22throw err; 23 24/* 25 AdvancedError: hello, world 26 bar baz 27 at tryReadme() (readme.js:20:1) 28*/
errorEx.line(str)
Creates a stack line using a delimiter
This is a helper function. It is to be used in lieu of writing a value object for
properties
values.
str
: The string to create
%s
to specify where in the string the value should go1var errorEx = require('error-ex'); 2 3var FileError = errorEx('FileError', {fileName: errorEx.line('in %s')}); 4 5var err = new FileError('problem reading file'); 6err.fileName = '/a/b/c/d/foo.js'; 7throw err; 8 9/* 10 FileError: problem reading file 11 in /a/b/c/d/foo.js 12 at tryReadme() (readme.js:7:1) 13*/
errorEx.append(str)
Appends to the error.message
string
This is a helper function. It is to be used in lieu of writing a value object for
properties
values.
str
: The string to append
%s
to specify where in the string the value should go1var errorEx = require('error-ex'); 2 3var SyntaxError = errorEx('SyntaxError', {fileName: errorEx.append('in %s')}); 4 5var err = new SyntaxError('improper indentation'); 6err.fileName = '/a/b/c/d/foo.js'; 7throw err; 8 9/* 10 SyntaxError: improper indentation in /a/b/c/d/foo.js 11 at tryReadme() (readme.js:7:1) 12*/
Licensed under the MIT License. You can find a copy of it in LICENSE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 4/24 approved changesets -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More