@alessiofrittoli/exception 3.2.0 → 3.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/dist/abort.js CHANGED
@@ -1,32 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkJG4AGGUJjs = require('./chunk-JG4AGGUJ.js');
4
- require('./chunk-KMJW7KZM.js');
5
-
6
- // src/abort.ts
7
- var AbortError = class extends _chunkJG4AGGUJjs.Exception {
8
- constructor(reason, options = {}) {
9
- const name = "AbortError";
10
- const {
11
- code = "ERR:ABORT" /* ABORT */,
12
- ...rest
13
- } = options;
14
- super(reason, { ...rest, name, code });
15
- }
16
- /**
17
- * Determines if the provided error is an instance of the AbortError class and has the ABORT ErrorCode.
18
- *
19
- * This won't work for `new DOMException( 'Abort reason', 'AbortError' )` since we type guard the checked value to `AbortError<TMessage>`.
20
- *
21
- * @template TMessage The type of the message property of the AbortError.
22
- *
23
- * @param error The error to check.
24
- * @returns `true` if the error is an `AbortError` and has the ABORT ErrorCode, `false` otherwise.
25
- */
26
- static isAbortError(error, code) {
27
- return super.isAbortError(error, code);
28
- }
29
- };
30
-
31
-
32
- exports.AbortError = AbortError;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYQB23ERMjs = require('./chunk-YQB23ERM.js');require('./chunk-5TBITEFP.js');var t=class extends _chunkYQB23ERMjs.a{constructor(r,o={}){let s="AbortError",{code:n="ERR:ABORT",...i}=o;super(r,{...i,name:s,code:n})}static isAbortError(r,o){return super.isAbortError(r,o)}};exports.AbortError = t;
package/dist/abort.mjs CHANGED
@@ -1,32 +1 @@
1
- import {
2
- Exception
3
- } from "./chunk-HGZVEYNW.mjs";
4
- import "./chunk-M2EF7GYS.mjs";
5
-
6
- // src/abort.ts
7
- var AbortError = class extends Exception {
8
- constructor(reason, options = {}) {
9
- const name = "AbortError";
10
- const {
11
- code = "ERR:ABORT" /* ABORT */,
12
- ...rest
13
- } = options;
14
- super(reason, { ...rest, name, code });
15
- }
16
- /**
17
- * Determines if the provided error is an instance of the AbortError class and has the ABORT ErrorCode.
18
- *
19
- * This won't work for `new DOMException( 'Abort reason', 'AbortError' )` since we type guard the checked value to `AbortError<TMessage>`.
20
- *
21
- * @template TMessage The type of the message property of the AbortError.
22
- *
23
- * @param error The error to check.
24
- * @returns `true` if the error is an `AbortError` and has the ABORT ErrorCode, `false` otherwise.
25
- */
26
- static isAbortError(error, code) {
27
- return super.isAbortError(error, code);
28
- }
29
- };
30
- export {
31
- AbortError
32
- };
1
+ import{a as e}from"./chunk-LFZW7VUK.mjs";import"./chunk-F4EU4T25.mjs";var t=class extends e{constructor(r,o={}){let s="AbortError",{code:n="ERR:ABORT",...i}=o;super(r,{...i,name:s,code:n})}static isAbortError(r,o){return super.isAbortError(r,o)}};export{t as AbortError};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var O=(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.TOO_MANY="ERR:TOOMANY",R.QUOTA_REACHED="ERR:QUOTAREACHED",R.NOT_FOUND="ERR:NOTFOUND",R.OFFLINE="ERR:INTERNETDISCONNECTED",R))(O||{});exports.a = O;
@@ -0,0 +1 @@
1
+ var O=(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.TOO_MANY="ERR:TOOMANY",R.QUOTA_REACHED="ERR:QUOTAREACHED",R.NOT_FOUND="ERR:NOTFOUND",R.OFFLINE="ERR:INTERNETDISCONNECTED",R))(O||{});export{O as a};
@@ -0,0 +1 @@
1
+ var o=class t 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 t||typeof e=="object"&&"__typename"in e&&e.__typename==="Exception"}static isAbortError(e,s="ERR:ABORT"){return t.isException(e)&&(e.name==="AbortError"||e.code===s)}toJSON(){return{...this,message:this.message,cause:this.cause}}};export{o as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var o=class t 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 t||typeof e=="object"&&"__typename"in e&&e.__typename==="Exception"}static isAbortError(e,s="ERR:ABORT"){return t.isException(e)&&(e.name==="AbortError"||e.code===s)}toJSON(){return{...this,message:this.message,cause:this.cause}}};exports.a = o;
package/dist/code.js CHANGED
@@ -1,6 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkKMJW7KZMjs = require('./chunk-KMJW7KZM.js');
4
-
5
-
6
- exports.ErrorCode = _chunkKMJW7KZMjs.ErrorCode;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5TBITEFPjs = require('./chunk-5TBITEFP.js');exports.ErrorCode = _chunk5TBITEFPjs.a;
package/dist/code.mjs CHANGED
@@ -1,6 +1 @@
1
- import {
2
- ErrorCode
3
- } from "./chunk-M2EF7GYS.mjs";
4
- export {
5
- ErrorCode
6
- };
1
+ import{a}from"./chunk-F4EU4T25.mjs";export{a as ErrorCode};
package/dist/index.js CHANGED
@@ -1,7 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkJG4AGGUJjs = require('./chunk-JG4AGGUJ.js');
4
- require('./chunk-KMJW7KZM.js');
5
-
6
-
7
- exports.Exception = _chunkJG4AGGUJjs.Exception;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYQB23ERMjs = require('./chunk-YQB23ERM.js');require('./chunk-5TBITEFP.js');exports.Exception = _chunkYQB23ERMjs.a;
package/dist/index.mjs CHANGED
@@ -1,7 +1 @@
1
- import {
2
- Exception
3
- } from "./chunk-HGZVEYNW.mjs";
4
- import "./chunk-M2EF7GYS.mjs";
5
- export {
6
- Exception
7
- };
1
+ import{a}from"./chunk-LFZW7VUK.mjs";import"./chunk-F4EU4T25.mjs";export{a as Exception};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alessiofrittoli/exception",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Handle errors with ease",
5
5
  "author": {
6
6
  "name": "Alessio Frittoli",
@@ -35,19 +35,34 @@
35
35
  ],
36
36
  "exports": {
37
37
  ".": {
38
- "types": "./dist/index.d.ts",
39
- "import": "./dist/index.mjs",
40
- "require": "./dist/index.js"
38
+ "import": {
39
+ "types": "./dist/index.d.mts",
40
+ "default": "./dist/index.mjs"
41
+ },
42
+ "require": {
43
+ "types": "./dist/index.d.ts",
44
+ "default": "./dist/index.js"
45
+ }
41
46
  },
42
47
  "./code": {
43
- "types": "./dist/code.d.ts",
44
- "import": "./dist/code.mjs",
45
- "require": "./dist/code.js"
48
+ "import": {
49
+ "types": "./dist/code.d.mts",
50
+ "default": "./dist/code.mjs"
51
+ },
52
+ "require": {
53
+ "types": "./dist/code.d.ts",
54
+ "default": "./dist/code.js"
55
+ }
46
56
  },
47
57
  "./abort": {
48
- "types": "./dist/abort.d.ts",
49
- "import": "./dist/abort.mjs",
50
- "require": "./dist/abort.js"
58
+ "import": {
59
+ "types": "./dist/abort.d.mts",
60
+ "default": "./dist/abort.mjs"
61
+ },
62
+ "require": {
63
+ "types": "./dist/abort.d.ts",
64
+ "default": "./dist/abort.js"
65
+ }
51
66
  }
52
67
  },
53
68
  "sideEffects": false,
@@ -55,11 +70,11 @@
55
70
  "//1a": "*********************************************************************",
56
71
  "//1b": "******************** DEV - BUILD - LINT - RELEASE *******************",
57
72
  "//1c": "*********************************************************************",
58
- "dev": "NODE_ENV=development tsup --watch",
59
- "build:prod": "NODE_ENV=production tsup",
73
+ "dev": "cross-env NODE_ENV=development tsup --watch",
74
+ "build:prod": "cross-env NODE_ENV=production tsup",
60
75
  "build": "pnpm lint && pnpm test:ci && pnpm build:prod",
61
76
  "lint": "eslint",
62
- "release": "node scripts/publish.js --verbose --npm",
77
+ "release": "node scripts/release.js --verbose --npm",
63
78
  "//2a": "*********************************************************************",
64
79
  "//2b": "***************************** UNIT TESTS ****************************",
65
80
  "//2c": "*********************************************************************",
@@ -75,27 +90,23 @@
75
90
  "test:coverage:serve": "concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\""
76
91
  },
77
92
  "devDependencies": {
78
- "@alessiofrittoli/node-scripts": "^2.5.0",
79
- "@eslint/js": "^9.25.1",
80
- "@jest/globals": "^29.7.0",
81
- "@types/jest": "^29.5.14",
82
- "@types/node": "^22.15.3",
83
- "concurrently": "^9.1.2",
84
- "dotenv": "^16.5.0",
85
- "esbuild": "0.25.3",
86
- "eslint": "^9.25.1",
87
- "globals": "^16.0.0",
93
+ "@alessiofrittoli/node-scripts": "^3.2.0",
94
+ "@eslint/js": "^9.39.1",
95
+ "@jest/globals": "^30.2.0",
96
+ "@types/jest": "^30.0.0",
97
+ "@types/node": "^24.10.1",
98
+ "concurrently": "^9.2.1",
99
+ "cross-env": "^10.1.0",
100
+ "dotenv": "^17.2.3",
101
+ "esbuild": "0.27.0",
102
+ "eslint": "^9.39.1",
103
+ "globals": "^16.5.0",
88
104
  "http-server": "^14.1.1",
89
- "jest": "^29.7.0",
90
- "ts-jest": "^29.3.2",
105
+ "jest": "^30.2.0",
106
+ "ts-jest": "^29.4.6",
91
107
  "ts-node": "^10.9.2",
92
- "tsup": "^8.4.0",
93
- "typescript": "^5.8.3",
94
- "typescript-eslint": "^8.31.1"
95
- },
96
- "pnpm": {
97
- "onlyBuiltDependencies": [
98
- "esbuild"
99
- ]
108
+ "tsup": "^8.5.1",
109
+ "typescript": "^5.9.3",
110
+ "typescript-eslint": "^8.48.1"
100
111
  }
101
112
  }
@@ -1,59 +0,0 @@
1
- // src/index.ts
2
- var Exception = class _Exception extends Error {
3
- /**
4
- * Constructs a new Exception instance.
5
- *
6
- * @param message The message describing the exception.
7
- * @param options Additional options for the exception.
8
- */
9
- constructor(message, options) {
10
- super("", options);
11
- this.__typename = "Exception";
12
- this.name = options.name || this.__typename;
13
- this.message = message;
14
- this.code = options.code;
15
- this.status = options.status;
16
- }
17
- /**
18
- * Determines if the provided error is an instance of the Exception class.
19
- *
20
- * @template TMessage The type of the message property of the Exception.
21
- * @template TCode The type of the code property of the Exception.
22
- *
23
- * @param error The error to check.
24
- * @returns `true` if the error is an instance of Exception or has a `__typename` property equal to 'Exception', `false` otherwise.
25
- */
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- static isException(error) {
28
- return error instanceof _Exception || typeof error === "object" && "__typename" in error && error.__typename === "Exception";
29
- }
30
- /**
31
- * Determines if the provided error is an instance of the Exception class and has the ABORT ErrorCode.
32
- *
33
- * This won't work for `new DOMException( 'Abort reason', 'AbortError' )` since we type guard the checked value to `Exception<TMessage, ErrorCode.ABORT>`.
34
- *
35
- * @template TMessage The type of the message property of the Exception.
36
- *
37
- * @param error The error to check.
38
- * @returns `true` if the error is an `Exception` and has the ABORT ErrorCode, `false` otherwise.
39
- */
40
- static isAbortError(error, code = "ERR:ABORT" /* ABORT */) {
41
- return _Exception.isException(error) && (error.name === "AbortError" || error.code === code);
42
- }
43
- /**
44
- * Converts the instance to a JSON object.
45
- *
46
- * @returns A JSON representation of the instance, including the message property.
47
- */
48
- toJSON() {
49
- return {
50
- ...this,
51
- message: this.message,
52
- cause: this.cause
53
- };
54
- }
55
- };
56
-
57
- export {
58
- Exception
59
- };
@@ -1,59 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts
2
- var Exception = class _Exception extends Error {
3
- /**
4
- * Constructs a new Exception instance.
5
- *
6
- * @param message The message describing the exception.
7
- * @param options Additional options for the exception.
8
- */
9
- constructor(message, options) {
10
- super("", options);
11
- this.__typename = "Exception";
12
- this.name = options.name || this.__typename;
13
- this.message = message;
14
- this.code = options.code;
15
- this.status = options.status;
16
- }
17
- /**
18
- * Determines if the provided error is an instance of the Exception class.
19
- *
20
- * @template TMessage The type of the message property of the Exception.
21
- * @template TCode The type of the code property of the Exception.
22
- *
23
- * @param error The error to check.
24
- * @returns `true` if the error is an instance of Exception or has a `__typename` property equal to 'Exception', `false` otherwise.
25
- */
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- static isException(error) {
28
- return error instanceof _Exception || typeof error === "object" && "__typename" in error && error.__typename === "Exception";
29
- }
30
- /**
31
- * Determines if the provided error is an instance of the Exception class and has the ABORT ErrorCode.
32
- *
33
- * This won't work for `new DOMException( 'Abort reason', 'AbortError' )` since we type guard the checked value to `Exception<TMessage, ErrorCode.ABORT>`.
34
- *
35
- * @template TMessage The type of the message property of the Exception.
36
- *
37
- * @param error The error to check.
38
- * @returns `true` if the error is an `Exception` and has the ABORT ErrorCode, `false` otherwise.
39
- */
40
- static isAbortError(error, code = "ERR:ABORT" /* ABORT */) {
41
- return _Exception.isException(error) && (error.name === "AbortError" || error.code === code);
42
- }
43
- /**
44
- * Converts the instance to a JSON object.
45
- *
46
- * @returns A JSON representation of the instance, including the message property.
47
- */
48
- toJSON() {
49
- return {
50
- ...this,
51
- message: this.message,
52
- cause: this.cause
53
- };
54
- }
55
- };
56
-
57
-
58
-
59
- exports.Exception = Exception;
@@ -1,18 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/code.ts
2
- var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
3
- ErrorCode2["UNKNOWN"] = "ERR:UNKNOWN";
4
- ErrorCode2["ABORT"] = "ERR:ABORT";
5
- ErrorCode2["EMPTY_VALUE"] = "ERR:EMPTYVALUE";
6
- ErrorCode2["WRONG_VALUE"] = "ERR:WRONGVALUE";
7
- ErrorCode2["EXPIRED"] = "ERR:EXPIRED";
8
- ErrorCode2["TOO_EARLY"] = "ERR:TOOEARLY";
9
- ErrorCode2["TOO_MANY"] = "ERR:TOOMANY";
10
- ErrorCode2["QUOTA_REACHED"] = "ERR:QUOTAREACHED";
11
- ErrorCode2["NOT_FOUND"] = "ERR:NOTFOUND";
12
- ErrorCode2["OFFLINE"] = "ERR:INTERNETDISCONNECTED";
13
- return ErrorCode2;
14
- })(ErrorCode || {});
15
-
16
-
17
-
18
- exports.ErrorCode = ErrorCode;
@@ -1,18 +0,0 @@
1
- // src/code.ts
2
- var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
3
- ErrorCode2["UNKNOWN"] = "ERR:UNKNOWN";
4
- ErrorCode2["ABORT"] = "ERR:ABORT";
5
- ErrorCode2["EMPTY_VALUE"] = "ERR:EMPTYVALUE";
6
- ErrorCode2["WRONG_VALUE"] = "ERR:WRONGVALUE";
7
- ErrorCode2["EXPIRED"] = "ERR:EXPIRED";
8
- ErrorCode2["TOO_EARLY"] = "ERR:TOOEARLY";
9
- ErrorCode2["TOO_MANY"] = "ERR:TOOMANY";
10
- ErrorCode2["QUOTA_REACHED"] = "ERR:QUOTAREACHED";
11
- ErrorCode2["NOT_FOUND"] = "ERR:NOTFOUND";
12
- ErrorCode2["OFFLINE"] = "ERR:INTERNETDISCONNECTED";
13
- return ErrorCode2;
14
- })(ErrorCode || {});
15
-
16
- export {
17
- ErrorCode
18
- };