@alessiofrittoli/exception 4.1.0 → 4.2.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.
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../code/index.cjs"),t=require("../index.cjs");var n=class extends t.Exception{constructor(n={}){let{code:r=e.ErrorCode.ABORT,...i}=n;super({...i,name:t.ExceptionName.AbortError,code:r})}static isAbortError(e,t){return super.isAbortError(e,t)}};exports.AbortError=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../code/index.cjs"),t=require("../index.cjs");var n=class extends t.Exception{constructor(n={}){let{code:r=e.ErrorCode.ABORT,message:i=`signal is aborted without reason`,...a}=n;super({...a,name:t.ExceptionName.AbortError,message:i,code:r})}static isAbortError(e,t){return super.isAbortError(e,t)}};exports.AbortError=n;
@@ -1,6 +1,5 @@
1
1
  import { ErrorCode } from "../code/index.cjs";
2
2
  import { Exception, ExceptionOptions } from "../index.cjs";
3
- //#region src/abort/index.d.ts
4
3
  /**
5
4
  * Interface representing the options for an Exception.
6
5
  *
@@ -25,5 +24,4 @@ export declare class AbortError<T = ErrorCode> extends Exception<T> implements A
25
24
  * @returns `true` if the error is an `AbortError` and has the ABORT ErrorCode, `false` otherwise.
26
25
  */
27
26
  static isAbortError<T = ErrorCode>(error: any, code?: T): error is AbortError<T>;
28
- }
29
- //#endregion
27
+ }
@@ -1,6 +1,5 @@
1
1
  import { ErrorCode } from "../code/index.mjs";
2
2
  import { Exception, ExceptionOptions } from "../index.mjs";
3
- //#region src/abort/index.d.ts
4
3
  /**
5
4
  * Interface representing the options for an Exception.
6
5
  *
@@ -25,5 +24,4 @@ export declare class AbortError<T = ErrorCode> extends Exception<T> implements A
25
24
  * @returns `true` if the error is an `AbortError` and has the ABORT ErrorCode, `false` otherwise.
26
25
  */
27
26
  static isAbortError<T = ErrorCode>(error: any, code?: T): error is AbortError<T>;
28
- }
29
- //#endregion
27
+ }
@@ -1 +1 @@
1
- import{ErrorCode as e}from"../code/index.mjs";import{Exception as t,ExceptionName as n}from"../index.mjs";var r=class extends t{constructor(t={}){let{code:r=e.ABORT,...i}=t;super({...i,name:n.AbortError,code:r})}static isAbortError(e,t){return super.isAbortError(e,t)}};export{r as AbortError};
1
+ import{ErrorCode as e}from"../code/index.mjs";import{Exception as t,ExceptionName as n}from"../index.mjs";var r=class extends t{constructor(t={}){let{code:r=e.ABORT,message:i=`signal is aborted without reason`,...a}=t;super({...a,name:n.AbortError,message:i,code:r})}static isAbortError(e,t){return super.isAbortError(e,t)}};export{r as AbortError};
@@ -1,4 +1,3 @@
1
- //#region src/code/index.d.ts
2
1
  /**
3
2
  * Most common error codes.
4
3
  *
@@ -15,5 +14,4 @@ export declare const ErrorCode: {
15
14
  readonly NOT_FOUND: "ERR:NOTFOUND";
16
15
  readonly OFFLINE: "ERR:INTERNETDISCONNECTED";
17
16
  };
18
- export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
19
- //#endregion
17
+ export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
@@ -1,4 +1,3 @@
1
- //#region src/code/index.d.ts
2
1
  /**
3
2
  * Most common error codes.
4
3
  *
@@ -15,5 +14,4 @@ export declare const ErrorCode: {
15
14
  readonly NOT_FOUND: "ERR:NOTFOUND";
16
15
  readonly OFFLINE: "ERR:INTERNETDISCONNECTED";
17
16
  };
18
- export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
19
- //#endregion
17
+ export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./code/index.cjs"),t={Exception:`Exception`,AbortError:`AbortError`,NotAllowedError:`NotAllowedError`,NotFoundError:`NotFoundError`,NotSupportedError:`NotSupportedError`,InvalidStateError:`InvalidStateError`,InvalidAccessError:`InvalidAccessError`,NetworkError:`NetworkError`,SecurityError:`SecurityError`,TimeoutError:`TimeoutError`,QuotaExceededError:`QuotaExceededError`,DataError:`DataError`,EncodingError:`EncodingError`,OperationError:`OperationError`,ConstraintError:`ConstraintError`,TransactionInactiveError:`TransactionInactiveError`,ReadOnlyError:`ReadOnlyError`,VersionError:`VersionError`,NoModificationAllowedError:`NoModificationAllowedError`,HierarchyRequestError:`HierarchyRequestError`,WrongDocumentError:`WrongDocumentError`,InvalidCharacterError:`InvalidCharacterError`,NamespaceError:`NamespaceError`,SyntaxError:`SyntaxError`,DataCloneError:`DataCloneError`,URLMismatchError:`URLMismatchError`,InvalidModificationError:`InvalidModificationError`,NotReadableError:`NotReadableError`};var n=class n extends Error{__typename=t.Exception;name=this.__typename;message;title;description;code;isCritical;status;cause;constructor(e){let{message:t=`Unknown error.`}=e;super(t),e.name&&(this.name=e.name),this.message=t,this.title=e.title,this.description=e.description,this.code=e.code,this.isCritical=e.isCritical??!1,this.status=e.status,this.cause=n.isException(e.cause)?new n(e.cause):e.cause}static isException(e){return e instanceof n||typeof e==`object`&&`__typename`in e&&e.__typename===t.Exception}static isAbortError(r,i=e.ErrorCode.ABORT){return n.isException(r)&&(r.name===t.AbortError||r.code===i)}toJSON(){return{...this,message:this.message,cause:this.cause}}};exports.Exception=n,exports.ExceptionName=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./code/index.cjs"),t={Exception:`Exception`,AbortError:`AbortError`,NotAllowedError:`NotAllowedError`,NotFoundError:`NotFoundError`,NotSupportedError:`NotSupportedError`,InvalidStateError:`InvalidStateError`,InvalidAccessError:`InvalidAccessError`,NetworkError:`NetworkError`,SecurityError:`SecurityError`,TimeoutError:`TimeoutError`,QuotaExceededError:`QuotaExceededError`,DataError:`DataError`,EncodingError:`EncodingError`,OperationError:`OperationError`,ConstraintError:`ConstraintError`,TransactionInactiveError:`TransactionInactiveError`,ReadOnlyError:`ReadOnlyError`,VersionError:`VersionError`,NoModificationAllowedError:`NoModificationAllowedError`,HierarchyRequestError:`HierarchyRequestError`,WrongDocumentError:`WrongDocumentError`,InvalidCharacterError:`InvalidCharacterError`,NamespaceError:`NamespaceError`,SyntaxError:`SyntaxError`,DataCloneError:`DataCloneError`,URLMismatchError:`URLMismatchError`,InvalidModificationError:`InvalidModificationError`,NotReadableError:`NotReadableError`};var n=class n extends Error{__typename=t.Exception;name=this.__typename;message;title;description;code;isCritical;status;cause;constructor(e){let{message:t=`Unknown error.`}=e;super(t),e.name&&(this.name=e.name),this.message=t,this.title=e.title,this.description=e.description,this.code=e.code,this.isCritical=e.isCritical??!1,this.status=e.status,this.cause=n.isException(e.cause)?new n(e.cause):e.cause}static isException(e){return e instanceof n||!!e&&typeof e==`object`&&`__typename`in e&&e.__typename===t.Exception}static isAbortError(r,i=e.ErrorCode.ABORT){return n.isException(r)&&(r.name===t.AbortError||r.code===i)}toJSON(){return{name:this.name,__typename:this.__typename,message:this.message,code:this.code,title:this.title,description:this.description,isCritical:this.isCritical,status:this.status,cause:this.cause}}};exports.Exception=n,exports.ExceptionName=t;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ErrorCode } from "./code/index.cjs";
2
- //#region src/error-names.d.ts
3
2
  /**
4
3
  * Exception Name.
5
4
  *
@@ -36,8 +35,9 @@ export declare const ExceptionName: {
36
35
  readonly NotReadableError: "NotReadableError";
37
36
  };
38
37
  export type ExceptionName = (typeof ExceptionName)[keyof typeof ExceptionName];
39
- //#endregion
40
- //#region src/index.d.ts
38
+ export interface JSONException<T = ErrorCode> extends Omit<Exception<T>, 'toJSON'> {
39
+ __typename: Exception['__typename'];
40
+ }
41
41
  /**
42
42
  * Interface representing the options for an Exception.
43
43
  *
@@ -172,6 +172,5 @@ export declare class Exception<T = ErrorCode> extends Error {
172
172
  *
173
173
  * @returns A JSON representation of the instance, including the message property.
174
174
  */
175
- toJSON(): this;
176
- }
177
- //#endregion
175
+ toJSON(): JSONException<T>;
176
+ }
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ErrorCode } from "./code/index.mjs";
2
- //#region src/error-names.d.ts
3
2
  /**
4
3
  * Exception Name.
5
4
  *
@@ -36,8 +35,9 @@ export declare const ExceptionName: {
36
35
  readonly NotReadableError: "NotReadableError";
37
36
  };
38
37
  export type ExceptionName = (typeof ExceptionName)[keyof typeof ExceptionName];
39
- //#endregion
40
- //#region src/index.d.ts
38
+ export interface JSONException<T = ErrorCode> extends Omit<Exception<T>, 'toJSON'> {
39
+ __typename: Exception['__typename'];
40
+ }
41
41
  /**
42
42
  * Interface representing the options for an Exception.
43
43
  *
@@ -172,6 +172,5 @@ export declare class Exception<T = ErrorCode> extends Error {
172
172
  *
173
173
  * @returns A JSON representation of the instance, including the message property.
174
174
  */
175
- toJSON(): this;
176
- }
177
- //#endregion
175
+ toJSON(): JSONException<T>;
176
+ }
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{ErrorCode as e}from"./code/index.mjs";const t={Exception:`Exception`,AbortError:`AbortError`,NotAllowedError:`NotAllowedError`,NotFoundError:`NotFoundError`,NotSupportedError:`NotSupportedError`,InvalidStateError:`InvalidStateError`,InvalidAccessError:`InvalidAccessError`,NetworkError:`NetworkError`,SecurityError:`SecurityError`,TimeoutError:`TimeoutError`,QuotaExceededError:`QuotaExceededError`,DataError:`DataError`,EncodingError:`EncodingError`,OperationError:`OperationError`,ConstraintError:`ConstraintError`,TransactionInactiveError:`TransactionInactiveError`,ReadOnlyError:`ReadOnlyError`,VersionError:`VersionError`,NoModificationAllowedError:`NoModificationAllowedError`,HierarchyRequestError:`HierarchyRequestError`,WrongDocumentError:`WrongDocumentError`,InvalidCharacterError:`InvalidCharacterError`,NamespaceError:`NamespaceError`,SyntaxError:`SyntaxError`,DataCloneError:`DataCloneError`,URLMismatchError:`URLMismatchError`,InvalidModificationError:`InvalidModificationError`,NotReadableError:`NotReadableError`};var n=class n extends Error{__typename=t.Exception;name=this.__typename;message;title;description;code;isCritical;status;cause;constructor(e){let{message:t=`Unknown error.`}=e;super(t),e.name&&(this.name=e.name),this.message=t,this.title=e.title,this.description=e.description,this.code=e.code,this.isCritical=e.isCritical??!1,this.status=e.status,this.cause=n.isException(e.cause)?new n(e.cause):e.cause}static isException(e){return e instanceof n||typeof e==`object`&&`__typename`in e&&e.__typename===t.Exception}static isAbortError(r,i=e.ABORT){return n.isException(r)&&(r.name===t.AbortError||r.code===i)}toJSON(){return{...this,message:this.message,cause:this.cause}}};export{n as Exception,t as ExceptionName};
1
+ import{ErrorCode as e}from"./code/index.mjs";const t={Exception:`Exception`,AbortError:`AbortError`,NotAllowedError:`NotAllowedError`,NotFoundError:`NotFoundError`,NotSupportedError:`NotSupportedError`,InvalidStateError:`InvalidStateError`,InvalidAccessError:`InvalidAccessError`,NetworkError:`NetworkError`,SecurityError:`SecurityError`,TimeoutError:`TimeoutError`,QuotaExceededError:`QuotaExceededError`,DataError:`DataError`,EncodingError:`EncodingError`,OperationError:`OperationError`,ConstraintError:`ConstraintError`,TransactionInactiveError:`TransactionInactiveError`,ReadOnlyError:`ReadOnlyError`,VersionError:`VersionError`,NoModificationAllowedError:`NoModificationAllowedError`,HierarchyRequestError:`HierarchyRequestError`,WrongDocumentError:`WrongDocumentError`,InvalidCharacterError:`InvalidCharacterError`,NamespaceError:`NamespaceError`,SyntaxError:`SyntaxError`,DataCloneError:`DataCloneError`,URLMismatchError:`URLMismatchError`,InvalidModificationError:`InvalidModificationError`,NotReadableError:`NotReadableError`};var n=class n extends Error{__typename=t.Exception;name=this.__typename;message;title;description;code;isCritical;status;cause;constructor(e){let{message:t=`Unknown error.`}=e;super(t),e.name&&(this.name=e.name),this.message=t,this.title=e.title,this.description=e.description,this.code=e.code,this.isCritical=e.isCritical??!1,this.status=e.status,this.cause=n.isException(e.cause)?new n(e.cause):e.cause}static isException(e){return e instanceof n||!!e&&typeof e==`object`&&`__typename`in e&&e.__typename===t.Exception}static isAbortError(r,i=e.ABORT){return n.isException(r)&&(r.name===t.AbortError||r.code===i)}toJSON(){return{name:this.name,__typename:this.__typename,message:this.message,code:this.code,title:this.title,description:this.description,isCritical:this.isCritical,status:this.status,cause:this.cause}}};export{n as Exception,t as ExceptionName};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alessiofrittoli/exception",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "Handle errors with ease",
5
5
  "type": "module",
6
6
  "author": {
@@ -62,26 +62,26 @@
62
62
  },
63
63
  "sideEffects": false,
64
64
  "devDependencies": {
65
- "@alessiofrittoli/node-scripts": "4.0.0-alpha.3",
66
- "@alessiofrittoli/package-configs": "1.6.0",
65
+ "@alessiofrittoli/node-scripts": "^4.2.0",
66
+ "@alessiofrittoli/package-configs": "^1.9.0",
67
67
  "@types/node": "^24.19.1",
68
- "@vitest/coverage-v8": "^5.0.3",
69
- "concurrently": "^9.2.1",
68
+ "@vitest/coverage-v8": "^5.0.5",
69
+ "concurrently": "^10.0.6",
70
70
  "http-server": "^14.1.1",
71
- "oxlint": "^1.86.0",
72
- "prettier": "^3.9.9",
71
+ "oxlint": "^1.89.0",
72
+ "oxlint-tsgolint": "^7.0.2005",
73
+ "prettier": "^3.9.10",
73
74
  "prettier-plugin-sort-imports": "^1.8.11",
74
- "tsdown": "^0.23.0",
75
+ "tsdown": "^0.23.2",
75
76
  "typescript": "^6.0.3",
76
- "vite": "^8.3.2",
77
- "vitest": "^5.0.3"
77
+ "vitest": "^5.0.5"
78
78
  },
79
79
  "scripts": {
80
80
  "//1a": "*********************************************************************",
81
81
  "//1b": "******************** DEV - BUILD - LINT - RELEASE *******************",
82
82
  "//1c": "*********************************************************************",
83
83
  "dev": "tsdown --watch",
84
- "build": "pnpm lint && pnpm tsc && pnpm tsdown",
84
+ "build": "pnpm lint && pnpm tsdown",
85
85
  "lint": "oxlint --report-unused-disable-directives --max-warnings 0",
86
86
  "release": "node scripts/release.ts --verbose --npm",
87
87
  "//2a": "*********************************************************************",