@leonardoraele/err
Advanced tools
+21
| MIT License | ||
| Copyright (c) 2025 Leonaro Raele | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
+36
| # Err | ||
|  | ||
| ## Install | ||
| npm install @leonardoraele/err | ||
| ## Usage | ||
| ```js | ||
| import { Err } from '@leonardoraele/err'; | ||
| ``` | ||
| ```js | ||
| new Err('This is an error') | ||
| .with({ context: 'Add JSON data this way' }) // Use `.with()` to add content information tot he error | ||
| .causes('Another error') // Use `.causes()` to create a new error that has `this` error as a | ||
| // cause. When the new error is stringified (e.g. in the console), | ||
| // the cause will be displayed in a separated. | ||
| .throw(); // Use `throw()` to throw the error in an expression instead of | ||
| // requiring a dedicated statement. | ||
| ``` | ||
| Output in Node 23: | ||
| ``` | ||
| Uncaught: | ||
| Err [Error]: Another error | ||
| at ... { | ||
| details: undefined, | ||
| [cause]: Err [Error]: This is an error | ||
| at ... { | ||
| details: { context: 'Add JSON data this way' } | ||
| } | ||
| } | ||
| ``` |
+5
-3
| { | ||
| "name": "@leonardoraele/err", | ||
| "version": "0.1.0", | ||
| "description": "An error object with support for adding context data", | ||
| "version": "0.1.1", | ||
| "description": "A simple error class with support for adding context data", | ||
| "author": "Leonardo Raele <leonardoraele@gmail.com>", | ||
| "license": "MIT", | ||
| "type": "module", | ||
| "files": ["dist"], | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "exports": "./dist/index.js", | ||
@@ -10,0 +12,0 @@ "scripts": { |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
5965
54.41%5
66.67%1
-50%37
Infinity%