@alessiofrittoli/exception 3.4.0 → 4.0.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 +190 -249
- package/dist/abort/index.cjs +1 -0
- package/dist/abort/index.d.cts +29 -0
- package/dist/abort/index.d.mts +29 -0
- package/dist/abort/index.mjs +1 -0
- package/dist/code/index.cjs +1 -0
- package/dist/code/index.d.cts +19 -0
- package/dist/code/index.d.mts +19 -0
- package/dist/code/index.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +177 -0
- package/dist/index.d.mts +164 -58
- package/dist/index.mjs +1 -1
- package/license.md +1 -1
- package/package.json +34 -45
- package/dist/abort.d.mts +0 -35
- package/dist/abort.d.ts +0 -35
- package/dist/abort.js +0 -1
- package/dist/abort.mjs +0 -1
- package/dist/chunk-OBRRZX4D.js +0 -1
- package/dist/chunk-PSRQLNM6.js +0 -1
- package/dist/chunk-RAHIXT6K.mjs +0 -1
- package/dist/chunk-VBWDYSF3.mjs +0 -1
- package/dist/code.d.mts +0 -19
- package/dist/code.d.ts +0 -19
- package/dist/code.js +0 -1
- package/dist/code.mjs +0 -1
- package/dist/index.d.ts +0 -71
- package/dist/index.js +0 -1
package/dist/code.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Most common error codes.
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
declare const ErrorCode: {
|
|
6
|
-
readonly UNKNOWN: "ERR:UNKNOWN";
|
|
7
|
-
readonly ABORT: "ERR:ABORT";
|
|
8
|
-
readonly EMPTY_VALUE: "ERR:EMPTYVALUE";
|
|
9
|
-
readonly WRONG_VALUE: "ERR:WRONGVALUE";
|
|
10
|
-
readonly EXPIRED: "ERR:EXPIRED";
|
|
11
|
-
readonly TOO_EARLY: "ERR:TOOEARLY";
|
|
12
|
-
readonly TOO_MANY: "ERR:TOOMANY";
|
|
13
|
-
readonly QUOTA_REACHED: "ERR:QUOTAREACHED";
|
|
14
|
-
readonly NOT_FOUND: "ERR:NOTFOUND";
|
|
15
|
-
readonly OFFLINE: "ERR:INTERNETDISCONNECTED";
|
|
16
|
-
};
|
|
17
|
-
type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
|
|
18
|
-
|
|
19
|
-
export { ErrorCode };
|
package/dist/code.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPSRQLNM6js = require('./chunk-PSRQLNM6.js');exports.ErrorCode = _chunkPSRQLNM6js.a;
|
package/dist/code.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-VBWDYSF3.mjs";export{a as ErrorCode};
|
package/dist/index.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ErrorCode } from './code.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interface representing the options for an Exception.
|
|
5
|
-
*
|
|
6
|
-
* @template TCode The type of the error code.
|
|
7
|
-
* @extends ErrorOptions
|
|
8
|
-
*/
|
|
9
|
-
interface ExceptionOptions<TCode = ErrorCode> extends ErrorOptions {
|
|
10
|
-
/** The error code associated with the Exception. */
|
|
11
|
-
code: TCode;
|
|
12
|
-
/** The name of the Exception. */
|
|
13
|
-
name?: string;
|
|
14
|
-
/** The HTTP status code associated with the Exception. */
|
|
15
|
-
status?: number;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Exception Class.
|
|
19
|
-
*
|
|
20
|
-
* @template TMessage The type of the message property of the Exception. Defaults to `string`.
|
|
21
|
-
* @template TCode The type of the code property of the Exception. Defaults to `ErrorCode`.
|
|
22
|
-
*
|
|
23
|
-
* @extends Error
|
|
24
|
-
* @implements ExceptionOptions<TCode>
|
|
25
|
-
*/
|
|
26
|
-
declare class Exception<TMessage = string, TCode = ErrorCode> extends Error implements ExceptionOptions<TCode> {
|
|
27
|
-
message: TMessage;
|
|
28
|
-
status: number | undefined;
|
|
29
|
-
name: string;
|
|
30
|
-
private __typename;
|
|
31
|
-
code: TCode;
|
|
32
|
-
/**
|
|
33
|
-
* Constructs a new Exception instance.
|
|
34
|
-
*
|
|
35
|
-
* @param message The message describing the exception.
|
|
36
|
-
* @param options Additional options for the exception.
|
|
37
|
-
*/
|
|
38
|
-
constructor(message: TMessage, options: ExceptionOptions<TCode>);
|
|
39
|
-
/**
|
|
40
|
-
* Determines if the provided error is an instance of the Exception class.
|
|
41
|
-
*
|
|
42
|
-
* @template TMessage The type of the message property of the Exception.
|
|
43
|
-
* @template TCode The type of the code property of the Exception.
|
|
44
|
-
*
|
|
45
|
-
* @param error The error to check.
|
|
46
|
-
* @returns `true` if the error is an instance of Exception or has a `__typename` property equal to 'Exception', `false` otherwise.
|
|
47
|
-
*/
|
|
48
|
-
static isException<TMessage = string, TCode = ErrorCode>(error: any): error is Exception<TMessage, TCode>;
|
|
49
|
-
/**
|
|
50
|
-
* Determines if the provided error is an instance of the Exception class and has the ABORT ErrorCode.
|
|
51
|
-
*
|
|
52
|
-
* This won't work for `new DOMException( 'Abort reason', 'AbortError' )` since we type guard the checked value to `Exception<TMessage, ErrorCode.ABORT>`.
|
|
53
|
-
*
|
|
54
|
-
* @template TMessage The type of the message property of the Exception.
|
|
55
|
-
*
|
|
56
|
-
* @param error The error to check.
|
|
57
|
-
* @returns `true` if the error is an `Exception` and has the ABORT ErrorCode, `false` otherwise.
|
|
58
|
-
*/
|
|
59
|
-
static isAbortError<TMessage = string, TCode = ErrorCode>(error: any, code?: TCode): error is Exception<TMessage, TCode>;
|
|
60
|
-
/**
|
|
61
|
-
* Converts the instance to a JSON object.
|
|
62
|
-
*
|
|
63
|
-
* @returns A JSON representation of the instance, including the message property.
|
|
64
|
-
*/
|
|
65
|
-
toJSON(): this & {
|
|
66
|
-
message: TMessage;
|
|
67
|
-
cause: unknown;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { Exception, type ExceptionOptions };
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOBRRZX4Djs = require('./chunk-OBRRZX4D.js');require('./chunk-PSRQLNM6.js');exports.Exception = _chunkOBRRZX4Djs.a;
|