Installations
npm install error-utils
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
8.1.3
NPM Version
5.0.3
Score
70
Supply Chain
98.8
Quality
75.1
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
zhaoyao91
Download Statistics
Total Downloads
2,063
Last Day
1
Last Week
20
Last Month
49
Last Year
173
GitHub Statistics
1 Stars
5 Commits
1 Forks
2 Watching
1 Branches
1 Contributors
Bundle Size
1.45 kB
Minified
631.00 B
Minified + Gzipped
Package Meta Information
Latest Version
2.0.0
Package Id
error-utils@2.0.0
Size
2.46 kB
NPM Version
5.0.3
Node Version
8.1.3
Total Downloads
Cumulative downloads
Total Downloads
2,063
Last day
0%
1
Compared to previous day
Last week
900%
20
Compared to previous week
Last month
716.7%
49
Compared to previous month
Last year
-3.9%
173
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
1
Js Error Utils
Features
- make error class
- chain errors
- convert error to object
- convert object to error
Installation
In your bash
1npm i -S error-utils
In your code
1const utils = require('error-utils')
API
makeError
func(name) => Error
func(BaseError, name) => Error
func(Error) => Error
Examples:
1// MyError is subclass of Error 2const MyError = makeError('MyError') 3 4// MyError is subclass of TypeError 5const MyError = makeError('MyError', TypeError) 6 7// MyError is subclass of SyntaxError with customized constructor 8const MyError = makeError(class MyError extends SyntaxError { 9 constructor (message, code) { 10 super(message) 11 this.code = code 12 } 13})
causedBy
func(error, cause) => error
Examples:
1const innerError1 = new InnerError('inner error 1')
2const innerError2 = new InnerError('inner error 2')
3const outerError = new OuterError('outer error')
4
5causedBy(innerError2, innerError1)
6causedBy(outterError, innerError2)
7
8// outerError.cause === innerError2
9// outerError.rootCause === innerError1
10// outerError.ownStack is the original stack of outerError
11// outerError.stack is with stacks of innerError2 and innerError1 appended
errorToObject
func(error) => object
1const error = new MyError('my error') 2const object = errorToObject(error) 3 4// object has name, message, stack, ownStack fields from error 5// object has all other direct fields of error 6// object.cause and object.rootError are parsed from error.cause and error.rootError by errorToObject
objectToError
func(object, [ErrorClass]) => error
1const error = new MyError('my error') 2const object = errorToObject(error) 3const newError = objectToError(object, MyError) 4 5// newError is instance of MyError 6// newError has name, message, stack, ownStack fields from object 7// newError has all other direct fields of object 8// newError.cause and newError.rootError are parsed from object.cause and object.rootError by objectToError 9// NOTE: newError is no longer instance of MyError
License
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
54 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2
- Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6
- Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9
- Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f
- Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p
- Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv
- Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8
- Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65
- Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq
- Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm
- Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f9cm-qmx5-m98h
- Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-6394-6h9h-cfjg
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3
- Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-g7q5-pjjr-gqvp
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
1.3
/10
Last Scanned on 2024-12-23
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