Installations
npm install custom-verror
Developer
particle-iot
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
12.6.0
NPM Version
6.11.3
Statistics
1 Stars
10 Commits
42 Watching
2 Branches
50 Contributors
Updated on 10 Mar 2020
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
43,600
Last day
-86%
8
Compared to previous day
Last week
-3.5%
246
Compared to previous week
Last month
42.6%
1,144
Compared to previous month
Last year
-35.2%
8,200
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
4
Custom VError
Simple class extending VError for easy custom error creation.
Usage
Here is the basic usage. For more use cases, see the tests.
1. Define your error
UserNotAllowedError.js
1'use strict'; 2 3const CustomVError = require('custom-verror'); 4 5// Replace UserNotAllowedError with your custom error name 6module.exports = class UserNotAllowedError extends CustomVError { 7 constructor(...args) { 8 super(...args); 9 // Provide a default message 10 this.message = this.message || 'User is not allowed to perform this action'; 11 } 12};
2. Throw your error
1const UserNotAllowedError = require('./UserNotAllowedError');
2
3function performAction() {
4 if (!isAllowed) {
5 throw new UserNotAllowedError({
6 // You can provide some error metadata. This will be appended to the message
7 info: {
8 user_id: user._id
9 }
10 })
11 }
12}
3. Catch your error
1try { 2 performAction(); 3} catch (ex) { 4 if (ex instanceof UserNotAllowedError) { 5 numberOfTimesUsersTriedToDoSomethingTheyWerentSupposedTo++; 6 // This will log the default message and the metadata in following format: 7 // "User is not allowed to perform this action user_id=FOO" 8 console.log(ex); 9 } 10}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 1/9 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.7
/10
Last Scanned on 2024-11-18
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