Gathering detailed insights and metrics for baseerr
Gathering detailed insights and metrics for baseerr
Gathering detailed insights and metrics for baseerr
Gathering detailed insights and metrics for baseerr
npm install baseerr
Typescript
Module System
Node Version
NPM Version
72.9
Supply Chain
99.4
Quality
79.6
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
80,736
Last Day
19
Last Week
174
Last Month
1,019
Last Year
21,263
2 Stars
32 Commits
3 Watching
13 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
2.0.6
Package Id
baseerr@2.0.6
Unpacked Size
37.71 kB
Size
8.39 kB
File Count
18
NPM Version
8.19.4
Node Version
16.20.2
Publised On
17 Apr 2024
Cumulative downloads
Total Downloads
Last day
-5%
19
Compared to previous day
Last week
12.3%
174
Compared to previous week
Last month
-91.7%
1,019
Compared to previous month
Last year
11.7%
21,263
Compared to previous year
A solid BaseError class that supports custom properties and wrapping errors
1npm i --save baseerr
1import BaseError from 'baseerr' 2 3class CustomError extends BaseError {} 4 5const err = new CustomError('boom') 6console.log(err.name // 'CustomError' 7console.log(err.stack) 8// CustomError: boom 9// anonymous (filename:5:17)
1import BaseError from 'baseerr' 2 3class CustomError extends BaseError {} 4 5try { 6 throw new Error('pow') 7} catch (_err) { 8 const err = CustomError.wrap('caught error', _err) 9 console.log(err.stack) 10 // CustomError: caught error 11 // anonymous (filename:8:17) 12 // ---- 13 // Error: pow 14 // anonymous (filename:6:9) 15}
1import BaseError from 'baseerr' 2 3class CustomError extends BaseError {} 4 5Promise.reject(new Error('pow')).catch((err) => 6 CustomError.wrapAndThrow('caught error', err), 7) 8// rejects with: 9// CustomError: caught error 10// anonymous (filename:6:3) 11// ---- 12// Error: pow 13// anonymous (filename:5:16)
1import BaseError from 'baseerr' 2 3class CustomError extends BaseError {} 4 5const err = new CustomError('boom', { foo: 10, bar: 20 }) 6console.log(err.foo) // 10 7console.log(err.bar) // 20 8console.log(err.stack) 9// CustomError: boom 10// anonymous (filename:5:17) 11// { 12// "foo": 10, 13// "bar": 20 14// } 15 16// TypeScripters use BaseError.create if you want to access extended properties with proper typing: 17const err = CustomError.create('boom', { foo: 10, bar: 20 }) 18console.log(err.foo) // 10 19console.log(err.bar) // 20
1import BaseError from 'baseerr' 2 3class FetchError extends BaseError {} 4class ResponseError extends BaseError {} 5class ApiError extends BaseError {} 6 7class ApiClient { 8 getData() { 9 const url = 'https://localhost:3000' 10 try { 11 const res = await Promise.race([ 12 timeout(2000).then(() => { 13 throw new TimeoutError('request timed out', { statusCode: 504, url }) 14 }), 15 fetch(url).catch( 16 FetchError.wrapAndThrow('network error', { statusCode: 503, url }), 17 ), 18 ]) 19 if (res.statusCode !== 200) { 20 throw new ResponseError('status: ${res.statusCode}', { 21 statusCode: res.statusCode, 22 url, 23 }) 24 } 25 return await res.json() 26 } catch (err) { 27 throw ApiError.wrap(err, { url, statusCode: err.statusCode || 500 }) 28 // ApiError: boom 29 // anonymous (filename:row:col) 30 // { 31 // "url": 'https://localhost:3000', 32 // "statusCode": 504 33 // } 34 // ---- 35 // TimedoutError: request timed out 36 // anonymous (filename:row:col) 37 // { 38 // "url": 'https://localhost:3000', 39 // "statusCode": 504 40 // } 41 } 42 } 43}
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/27 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
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
Reason
28 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
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