@alessiofrittoli/exception 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -68
- package/dist/code.js +2 -1
- package/dist/code.js.map +1 -0
- package/dist/code.mjs +2 -1
- package/dist/code.mjs.map +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -0
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -18,12 +18,12 @@ This documentation describes the `Exception` class, which provides a structured
|
|
|
18
18
|
|
|
19
19
|
- [Getting started](#getting-started)
|
|
20
20
|
- [API Reference](#api-reference)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
- [ExceptionOptions Interface](#exceptionoptions-interface)
|
|
22
|
+
- [Exception Class](#exception-class)
|
|
23
|
+
- [Usage Scenarios](#usage-scenarios)
|
|
24
24
|
- [Development](#development)
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
- [ESLint](#eslint)
|
|
26
|
+
- [Jest](#jest)
|
|
27
27
|
- [Contributing](#contributing)
|
|
28
28
|
- [Security](#security)
|
|
29
29
|
- [Credits](#made-with-)
|
|
@@ -87,12 +87,12 @@ The constructor initializes an `Exception` instance with a custom message and op
|
|
|
87
87
|
import { Exception } from '@alessiofrittoli/exception'
|
|
88
88
|
|
|
89
89
|
try {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
throw new Exception( 'Resource not found', {
|
|
91
|
+
code : 'ERR:NOTFOUND',
|
|
92
|
+
status : 404,
|
|
93
|
+
} )
|
|
94
94
|
} catch ( error ) {
|
|
95
|
-
|
|
95
|
+
console.error( error )
|
|
96
96
|
}
|
|
97
97
|
```
|
|
98
98
|
|
|
@@ -108,24 +108,24 @@ It supports also a JSON representation of the `Exception` class (commonly return
|
|
|
108
108
|
|
|
109
109
|
```ts
|
|
110
110
|
try {
|
|
111
|
-
|
|
111
|
+
throw new Exception( 'Something went wrong', { code: 'ERR:UNKNOWN' } )
|
|
112
112
|
} catch ( error ) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
if ( Exception.isException( error ) ) {
|
|
114
|
+
// we can safely access `Exception` properties
|
|
115
|
+
console.error( `Error [${ error.code }]: ${ error.message }` )
|
|
116
|
+
} else {
|
|
117
|
+
console.error( error )
|
|
118
|
+
}
|
|
119
119
|
}
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
```ts
|
|
123
123
|
/** Simulates JSON Exception returned by a server JSON Response. */
|
|
124
124
|
const error = (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
JSON.parse( JSON.stringify( new Exception( 'Exception with custom name.', {
|
|
126
|
+
code: 0,
|
|
127
|
+
name: 'AbortError',
|
|
128
|
+
} ) ) )
|
|
129
129
|
)
|
|
130
130
|
|
|
131
131
|
console.log( Exception.isException( error ) ) // Outputs: true
|
|
@@ -143,12 +143,12 @@ The `Exception` class is ideal for creating domain-specific errors with addition
|
|
|
143
143
|
|
|
144
144
|
```ts
|
|
145
145
|
try {
|
|
146
|
-
|
|
146
|
+
await fetch( ... )
|
|
147
147
|
} catch ( error ) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
// error thrown by the server: Exception( 'Wrong value.', { code: ErrorCode.WRONG_VALUE, status: 422 } )
|
|
149
|
+
if ( Exception.isException( error ) ) {
|
|
150
|
+
console.log( error.code ) // `error.code` is type of `ErrorCode`.
|
|
151
|
+
}
|
|
152
152
|
}
|
|
153
153
|
```
|
|
154
154
|
|
|
@@ -191,7 +191,7 @@ import { ErrorCode as Exception } from '@alessiofrittoli/exception/code'
|
|
|
191
191
|
/** Your project custom `ErrorCode`. */
|
|
192
192
|
export enum MyProjectErrorCode
|
|
193
193
|
{
|
|
194
|
-
|
|
194
|
+
INVALID_SIGN = 'ERR:INVALIDSIGN',
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
const ErrorCode = { Exception, MyProjectErrorCode }
|
|
@@ -217,8 +217,8 @@ import { Exception } from '@alessiofrittoli/exception'
|
|
|
217
217
|
import { ErrorCode } from '@alessiofrittoli/exception/code'
|
|
218
218
|
|
|
219
219
|
throw new Exception( 'Password is a required field to log you in.', {
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
code : ErrorCode.EMPTY_VALUE,
|
|
221
|
+
status : 422,
|
|
222
222
|
} )
|
|
223
223
|
```
|
|
224
224
|
|
|
@@ -229,8 +229,8 @@ import { Exception } from '@alessiofrittoli/exception'
|
|
|
229
229
|
import { ErrorCode } from '@/error-code' // previously created in `myproject/src/error-code.ts`
|
|
230
230
|
|
|
231
231
|
throw new Exception( 'Invalid signature.', {
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
code : ErrorCode.MyProjectErrorCode.INVALID_SIGN,
|
|
233
|
+
status : 403,
|
|
234
234
|
} )
|
|
235
235
|
```
|
|
236
236
|
|
|
@@ -240,18 +240,18 @@ throw new Exception( 'Invalid signature.', {
|
|
|
240
240
|
import { ErrorCode } from '@/error-code' // previously created in `myproject/src/error-code.ts`
|
|
241
241
|
|
|
242
242
|
try {
|
|
243
|
-
|
|
243
|
+
...
|
|
244
244
|
} catch ( error ) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
245
|
+
if ( Exception.isException<string, ErrorCode>( error ) ) {
|
|
246
|
+
switch ( error.code ) { // `error.code` is now type of `ErrorCode` (custom).
|
|
247
|
+
case ErrorCode.MyProjectErrorCode.INVALID_SIGN:
|
|
248
|
+
console.log( 'The signature is not valid.' )
|
|
249
|
+
break
|
|
250
|
+
case ErrorCode.Exception.UNKNOWN:
|
|
251
|
+
default:
|
|
252
|
+
console.log( 'Unexpected error occured.' )
|
|
254
253
|
}
|
|
254
|
+
}
|
|
255
255
|
}
|
|
256
256
|
```
|
|
257
257
|
|
|
@@ -340,30 +340,30 @@ If you believe you have found a security vulnerability, we encourage you to **_r
|
|
|
340
340
|
### Made with ☕
|
|
341
341
|
|
|
342
342
|
<table style='display:flex;gap:20px;'>
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
</table>
|
|
343
|
+
<tbody>
|
|
344
|
+
<tr>
|
|
345
|
+
<td>
|
|
346
|
+
<img alt="avatar" src='https://avatars.githubusercontent.com/u/35973186' style='width:60px;border-radius:50%;object-fit:contain;'>
|
|
347
|
+
</td>
|
|
348
|
+
<td>
|
|
349
|
+
<table style='display:flex;gap:2px;flex-direction:column;'>
|
|
350
|
+
<tbody>
|
|
351
|
+
<tr>
|
|
352
|
+
<td>
|
|
353
|
+
<a href='https://github.com/alessiofrittoli' target='_blank' rel='noopener'>Alessio Frittoli</a>
|
|
354
|
+
</td>
|
|
355
|
+
</tr>
|
|
356
|
+
<tr>
|
|
357
|
+
<td>
|
|
358
|
+
<small>
|
|
359
|
+
<a href='https://alessiofrittoli.it' target='_blank' rel='noopener'>https://alessiofrittoli.it</a> |
|
|
360
|
+
<a href='mailto:info@alessiofrittoli.it' target='_blank' rel='noopener'>info@alessiofrittoli.it</a>
|
|
361
|
+
</small>
|
|
362
|
+
</td>
|
|
363
|
+
</tr>
|
|
364
|
+
</tbody>
|
|
365
|
+
</table>
|
|
366
|
+
</td>
|
|
367
|
+
</tr>
|
|
368
|
+
</tbody>
|
|
369
|
+
</table>
|
package/dist/code.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
'use strict';var E=(R=>(R.UNKNOWN="ERR:UNKNOWN",R.ABORT="ERR:ABORT",R.EMPTY_VALUE="ERR:EMPTYVALUE",R.WRONG_VALUE="ERR:WRONGVALUE",R.EXPIRED="ERR:EXPIRED",R.TOO_EARLY="ERR:TOOEARLY",R))(E||{});exports.ErrorCode=E
|
|
1
|
+
'use strict';var E=(R=>(R.UNKNOWN="ERR:UNKNOWN",R.ABORT="ERR:ABORT",R.EMPTY_VALUE="ERR:EMPTYVALUE",R.WRONG_VALUE="ERR:WRONGVALUE",R.EXPIRED="ERR:EXPIRED",R.TOO_EARLY="ERR:TOOEARLY",R))(E||{});exports.ErrorCode=E;//# sourceMappingURL=code.js.map
|
|
2
|
+
//# sourceMappingURL=code.js.map
|
package/dist/code.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/code.ts"],"names":["ErrorCode"],"mappings":"aAIO,IAAKA,OAEXA,CAAA,CAAA,OAAA,CAAW,cACXA,CAAA,CAAA,KAAA,CAAS,YACTA,CAAA,CAAA,WAAA,CAAc,iBACdA,CAAA,CAAA,WAAA,CAAc,iBACdA,CAAA,CAAA,OAAA,CAAW,cACXA,CAAA,CAAA,SAAA,CAAY,eAPDA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA","file":"code.js","sourcesContent":["/**\n * Most common error codes.\n * \n */\nexport enum ErrorCode\n{\n\tUNKNOWN\t\t= 'ERR:UNKNOWN',\n\tABORT\t\t= 'ERR:ABORT',\n\tEMPTY_VALUE\t= 'ERR:EMPTYVALUE',\n\tWRONG_VALUE\t= 'ERR:WRONGVALUE',\n\tEXPIRED\t\t= 'ERR:EXPIRED',\n\tTOO_EARLY\t= 'ERR:TOOEARLY',\n}"]}
|
package/dist/code.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
var E=(R=>(R.UNKNOWN="ERR:UNKNOWN",R.ABORT="ERR:ABORT",R.EMPTY_VALUE="ERR:EMPTYVALUE",R.WRONG_VALUE="ERR:WRONGVALUE",R.EXPIRED="ERR:EXPIRED",R.TOO_EARLY="ERR:TOOEARLY",R))(E||{});export{E as ErrorCode}
|
|
1
|
+
var E=(R=>(R.UNKNOWN="ERR:UNKNOWN",R.ABORT="ERR:ABORT",R.EMPTY_VALUE="ERR:EMPTYVALUE",R.WRONG_VALUE="ERR:WRONGVALUE",R.EXPIRED="ERR:EXPIRED",R.TOO_EARLY="ERR:TOOEARLY",R))(E||{});export{E as ErrorCode};//# sourceMappingURL=code.mjs.map
|
|
2
|
+
//# sourceMappingURL=code.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/code.ts"],"names":["ErrorCode"],"mappings":"AAIO,IAAKA,OAEXA,CAAA,CAAA,OAAA,CAAW,cACXA,CAAA,CAAA,KAAA,CAAS,YACTA,CAAA,CAAA,WAAA,CAAc,iBACdA,CAAA,CAAA,WAAA,CAAc,iBACdA,CAAA,CAAA,OAAA,CAAW,cACXA,CAAA,CAAA,SAAA,CAAY,eAPDA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA","file":"code.mjs","sourcesContent":["/**\n * Most common error codes.\n * \n */\nexport enum ErrorCode\n{\n\tUNKNOWN\t\t= 'ERR:UNKNOWN',\n\tABORT\t\t= 'ERR:ABORT',\n\tEMPTY_VALUE\t= 'ERR:EMPTYVALUE',\n\tWRONG_VALUE\t= 'ERR:WRONGVALUE',\n\tEXPIRED\t\t= 'ERR:EXPIRED',\n\tTOO_EARLY\t= 'ERR:TOOEARLY',\n}"]}
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
'use strict';var t=class o extends Error{constructor(e,s){super("",s),this.typename="Exception",this.name=s.name||this.typename,this.message=e,this.code=s.code,this.status=s.status;}static isException(e){return e instanceof o||typeof e=="object"&&"typename"in e&&e.typename==="Exception"}toJSON(){return {...this,message:this.message,cause:this.cause}}};exports.Exception=t
|
|
1
|
+
'use strict';var t=class o extends Error{constructor(e,s){super("",s),this.typename="Exception",this.name=s.name||this.typename,this.message=e,this.code=s.code,this.status=s.status;}static isException(e){return e instanceof o||typeof e=="object"&&"typename"in e&&e.typename==="Exception"}toJSON(){return {...this,message:this.message,cause:this.cause}}};exports.Exception=t;//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["Exception","_Exception","message","options","error"],"mappings":"aA4BO,IAAMA,CAAN,CAAA,MAAMC,CAAwD,SAAA,KACrE,CAeC,WAAA,CAAaC,CAAmBC,CAAAA,CAAAA,CAChC,CACC,KAAA,CAAO,EAAIA,CAAAA,CAAQ,CAEnB,CAAA,IAAA,CAAK,QAAW,CAAA,WAAA,CAChB,IAAK,CAAA,IAAA,CAAQA,CAAQ,CAAA,IAAA,EAAQ,IAAK,CAAA,QAAA,CAClC,IAAK,CAAA,OAAA,CAAUD,CACf,CAAA,IAAA,CAAK,IAAQC,CAAAA,CAAAA,CAAQ,KACrB,IAAK,CAAA,MAAA,CAAUA,CAAQ,CAAA,OACxB,CAcA,OAAO,WAAmDC,CAAAA,CAAAA,CAC1D,CACC,OACCA,CAAiBH,YAAAA,CAAAA,EACf,OAAOG,CAAAA,EAAU,QAAY,EAAA,UAAA,GAAcA,GAASA,CAAM,CAAA,QAAA,GAAa,WAE3E,CAQA,MACA,EAAA,CACC,OAAO,CACN,GAAG,IAAA,CACH,OAAS,CAAA,IAAA,CAAK,OACd,CAAA,KAAA,CAAO,IAAK,CAAA,KACb,CACD,CACD","file":"index.js","sourcesContent":["import { ErrorCode } from './code'\n\n/**\n * Interface representing the options for an Exception.\n *\n * @template TCode - The type of the error code.\n * @extends ErrorOptions\n */\nexport interface ExceptionOptions<TCode = ErrorCode> extends ErrorOptions\n{\n\t/** The error code associated with the Exception. */\n\tcode: TCode\n\t/** The name of the Exception. */\n\tname?: string\n\t/** The HTTP status code associated with the Exception. */\n\tstatus?: number\n}\n\n\n/**\n * Exception Class.\n * \n * @template TMessage\tThe type of the message property of the Exception. Defaults to `string`.\n * @template TCode\t\tThe type of the code property of the Exception. Defaults to `ErrorCode`.\n *\n * @extends {Error}\n * @implements {ExceptionOptions<TCode>}\n */\nexport class Exception<TMessage = string, TCode = ErrorCode> extends Error implements ExceptionOptions<TCode>\n{\n\t// @ts-expect-error Type 'TMessage' is not assignable to type 'string'.ts(2416)\n\tmessage: TMessage\n\tstatus\n\tname\n\ttypename: 'Exception'\n\tcode\n\n\n\t/**\n\t * Constructs a new Exception instance.\n\t *\n\t * @param message The message describing the exception.\n\t * @param options Additional options for the exception.\n\t */\n\tconstructor( message: TMessage, options: ExceptionOptions<TCode> ) \n\t{\n\t\tsuper( '', options )\n\n\t\tthis.typename\t= 'Exception'\n\t\tthis.name\t\t= options.name || this.typename\n\t\tthis.message\t= message\n\t\tthis.code\t\t= options.code\n\t\tthis.status\t\t= options.status\n\t}\n\n\t\n\t\n\t/**\n\t * Determines if the provided error is an instance of the Exception class.\n\t *\n\t * @template TMessage\tThe type of the message property of the Exception.\n\t * @template TCode\t\tThe type of the code property of the Exception.\n\t * \n\t * @param\terror The error to check.\n\t * @returns\t`true` if the error is an instance of Exception or has a `typename` property equal to 'Exception', `false` otherwise.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tstatic isException<TMessage = string, TCode = ErrorCode>( error: any ): error is Exception<TMessage, TCode>\n\t{\n\t\treturn (\n\t\t\terror instanceof Exception ||\n\t\t\t( typeof error === 'object' && 'typename' in error && error.typename === 'Exception' )\n\t\t)\n\t}\n\n\n\t/**\n\t * Converts the instance to a JSON object.\n\t *\n\t * @returns A JSON representation of the instance, including the message property.\n\t */\n\ttoJSON()\n\t{\n\t\treturn {\n\t\t\t...this,\n\t\t\tmessage: this.message,\n\t\t\tcause: this.cause,\n\t\t}\n\t}\n}"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
var t=class o extends Error{constructor(e,s){super("",s),this.typename="Exception",this.name=s.name||this.typename,this.message=e,this.code=s.code,this.status=s.status;}static isException(e){return e instanceof o||typeof e=="object"&&"typename"in e&&e.typename==="Exception"}toJSON(){return {...this,message:this.message,cause:this.cause}}};export{t as Exception}
|
|
1
|
+
var t=class o extends Error{constructor(e,s){super("",s),this.typename="Exception",this.name=s.name||this.typename,this.message=e,this.code=s.code,this.status=s.status;}static isException(e){return e instanceof o||typeof e=="object"&&"typename"in e&&e.typename==="Exception"}toJSON(){return {...this,message:this.message,cause:this.cause}}};export{t as Exception};//# sourceMappingURL=index.mjs.map
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["Exception","_Exception","message","options","error"],"mappings":"AA4BO,IAAMA,CAAN,CAAA,MAAMC,CAAwD,SAAA,KACrE,CAeC,WAAA,CAAaC,CAAmBC,CAAAA,CAAAA,CAChC,CACC,KAAA,CAAO,EAAIA,CAAAA,CAAQ,CAEnB,CAAA,IAAA,CAAK,QAAW,CAAA,WAAA,CAChB,IAAK,CAAA,IAAA,CAAQA,CAAQ,CAAA,IAAA,EAAQ,IAAK,CAAA,QAAA,CAClC,IAAK,CAAA,OAAA,CAAUD,CACf,CAAA,IAAA,CAAK,IAAQC,CAAAA,CAAAA,CAAQ,KACrB,IAAK,CAAA,MAAA,CAAUA,CAAQ,CAAA,OACxB,CAcA,OAAO,WAAmDC,CAAAA,CAAAA,CAC1D,CACC,OACCA,CAAiBH,YAAAA,CAAAA,EACf,OAAOG,CAAAA,EAAU,QAAY,EAAA,UAAA,GAAcA,GAASA,CAAM,CAAA,QAAA,GAAa,WAE3E,CAQA,MACA,EAAA,CACC,OAAO,CACN,GAAG,IAAA,CACH,OAAS,CAAA,IAAA,CAAK,OACd,CAAA,KAAA,CAAO,IAAK,CAAA,KACb,CACD,CACD","file":"index.mjs","sourcesContent":["import { ErrorCode } from './code'\n\n/**\n * Interface representing the options for an Exception.\n *\n * @template TCode - The type of the error code.\n * @extends ErrorOptions\n */\nexport interface ExceptionOptions<TCode = ErrorCode> extends ErrorOptions\n{\n\t/** The error code associated with the Exception. */\n\tcode: TCode\n\t/** The name of the Exception. */\n\tname?: string\n\t/** The HTTP status code associated with the Exception. */\n\tstatus?: number\n}\n\n\n/**\n * Exception Class.\n * \n * @template TMessage\tThe type of the message property of the Exception. Defaults to `string`.\n * @template TCode\t\tThe type of the code property of the Exception. Defaults to `ErrorCode`.\n *\n * @extends {Error}\n * @implements {ExceptionOptions<TCode>}\n */\nexport class Exception<TMessage = string, TCode = ErrorCode> extends Error implements ExceptionOptions<TCode>\n{\n\t// @ts-expect-error Type 'TMessage' is not assignable to type 'string'.ts(2416)\n\tmessage: TMessage\n\tstatus\n\tname\n\ttypename: 'Exception'\n\tcode\n\n\n\t/**\n\t * Constructs a new Exception instance.\n\t *\n\t * @param message The message describing the exception.\n\t * @param options Additional options for the exception.\n\t */\n\tconstructor( message: TMessage, options: ExceptionOptions<TCode> ) \n\t{\n\t\tsuper( '', options )\n\n\t\tthis.typename\t= 'Exception'\n\t\tthis.name\t\t= options.name || this.typename\n\t\tthis.message\t= message\n\t\tthis.code\t\t= options.code\n\t\tthis.status\t\t= options.status\n\t}\n\n\t\n\t\n\t/**\n\t * Determines if the provided error is an instance of the Exception class.\n\t *\n\t * @template TMessage\tThe type of the message property of the Exception.\n\t * @template TCode\t\tThe type of the code property of the Exception.\n\t * \n\t * @param\terror The error to check.\n\t * @returns\t`true` if the error is an instance of Exception or has a `typename` property equal to 'Exception', `false` otherwise.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tstatic isException<TMessage = string, TCode = ErrorCode>( error: any ): error is Exception<TMessage, TCode>\n\t{\n\t\treturn (\n\t\t\terror instanceof Exception ||\n\t\t\t( typeof error === 'object' && 'typename' in error && error.typename === 'Exception' )\n\t\t)\n\t}\n\n\n\t/**\n\t * Converts the instance to a JSON object.\n\t *\n\t * @returns A JSON representation of the instance, including the message property.\n\t */\n\ttoJSON()\n\t{\n\t\treturn {\n\t\t\t...this,\n\t\t\tmessage: this.message,\n\t\t\tcause: this.cause,\n\t\t}\n\t}\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alessiofrittoli/exception",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Handle errors with ease",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Alessio Frittoli",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
32
33
|
"import": "./dist/index.mjs",
|
|
33
34
|
"require": "./dist/index.js"
|
|
34
35
|
},
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"build:watch": "tsup --watch",
|
|
45
46
|
"lint": "eslint",
|
|
46
47
|
"release": "node scripts/publish.js --verbose --npm",
|
|
47
|
-
"test": "
|
|
48
|
+
"test": "jest",
|
|
48
49
|
"test:watch": "jest --watchAll --verbose",
|
|
49
50
|
"test:jsdom": "JSDOM=true pnpm test:watch",
|
|
50
51
|
"test:ci": "jest --ci --verbose",
|
|
@@ -57,18 +58,18 @@
|
|
|
57
58
|
"test:coverage:jsdom:serve": "JSDOM=true pnpm test:coverage:serve",
|
|
58
59
|
"test:jest": "pnpm test:watch jest.test.ts",
|
|
59
60
|
"test:jest:jsdom": "JSDOM=true pnpm test:jest",
|
|
60
|
-
"test:exception": "pnpm test exception.test.ts"
|
|
61
|
+
"test:exception": "pnpm test:watch exception.test.ts"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@alessiofrittoli/node-scripts": "^2.2.1",
|
|
64
|
-
"@eslint/js": "^9.
|
|
65
|
+
"@eslint/js": "^9.18.0",
|
|
65
66
|
"@jest/globals": "^29.7.0",
|
|
66
67
|
"@types/jest": "^29.5.14",
|
|
67
|
-
"@types/node": "^22.10.
|
|
68
|
+
"@types/node": "^22.10.7",
|
|
68
69
|
"concurrently": "^9.1.2",
|
|
69
70
|
"dotenv": "^16.4.7",
|
|
70
71
|
"esbuild": "0.24.2",
|
|
71
|
-
"eslint": "^9.
|
|
72
|
+
"eslint": "^9.18.0",
|
|
72
73
|
"globals": "^15.14.0",
|
|
73
74
|
"http-server": "^14.1.1",
|
|
74
75
|
"jest": "^29.7.0",
|
|
@@ -77,6 +78,6 @@
|
|
|
77
78
|
"ts-node": "^10.9.2",
|
|
78
79
|
"tsup": "^8.3.5",
|
|
79
80
|
"typescript": "^5.7.3",
|
|
80
|
-
"typescript-eslint": "^8.
|
|
81
|
+
"typescript-eslint": "^8.21.0"
|
|
81
82
|
}
|
|
82
83
|
}
|