@little-nebulae/error 1.3.0 → 1.4.1

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/index.d.ts CHANGED
@@ -1,13 +1,10 @@
1
1
  import { Tagged, UnknownRecord } from "type-fest";
2
- //#region src/types.d.ts
3
2
  type BaseErrorMeta = UnknownRecord | null;
4
3
  interface BaseErrorType<TCode extends string, TCause = unknown, TMeta extends BaseErrorMeta = null> extends Error {
5
4
  cause: TCause;
6
5
  code: TCode;
7
6
  meta: TMeta;
8
7
  }
9
- //#endregion
10
- //#region src/classes/base.d.ts
11
8
  export declare abstract class BaseError<TCode extends string, TCause = unknown, TMeta extends BaseErrorMeta = null> extends Error implements BaseErrorType<TCode, TCause, TMeta> {
12
9
  abstract readonly name: string;
13
10
  cause: TCause;
@@ -19,24 +16,18 @@ export declare abstract class BaseError<TCode extends string, TCause = unknown,
19
16
  meta: TMeta;
20
17
  });
21
18
  }
22
- //#endregion
23
- //#region src/classes/unexpected.d.ts
24
19
  export declare const UNEXPECTED_ERROR_CODE = "UNEXPECTED_ERROR";
25
20
  export type UnexpectedErrorCode = typeof UNEXPECTED_ERROR_CODE;
26
21
  export declare class UnexpectedError<TCause = unknown, TMeta extends BaseErrorMeta = null> extends BaseError<UnexpectedErrorCode, TCause, TMeta> {
27
22
  readonly name = "UnexpectedError";
28
23
  readonly code = "UNEXPECTED_ERROR";
29
24
  }
30
- //#endregion
31
- //#region src/helpers/is/abort-error.d.ts
32
25
  export declare const ABORT_ERROR_NAME = "AbortError";
33
26
  export type AbortErrorName = typeof ABORT_ERROR_NAME;
34
27
  export declare const ABORT_ERROR_CODE = "ABORT_ERR";
35
28
  export type AbortErrorCode = typeof ABORT_ERROR_CODE;
36
29
  export type AbortError = Tagged<Error, AbortErrorName>;
37
30
  export declare function isAbortError(value: unknown): value is AbortError;
38
- //#endregion
39
- //#region src/classes/aborted.d.ts
40
31
  export declare const ABORTED_ERROR_CODE = "ABORTED_ERROR";
41
32
  export type AbortedErrorCode = typeof ABORTED_ERROR_CODE;
42
33
  export type AbortedErrorCause = AbortError | {
@@ -46,71 +37,42 @@ export declare class AbortedError<TCause extends AbortedErrorCause, TMeta extend
46
37
  readonly name = "AbortedError";
47
38
  readonly code = "ABORTED_ERROR";
48
39
  }
49
- //#endregion
50
- //#region src/helpers/is/timeout-error.d.ts
51
40
  export declare const TIMEOUT_ERROR_NAME = "TimeoutError";
52
41
  export type TimeoutErrorName = typeof TIMEOUT_ERROR_NAME;
53
42
  export type TimeoutError = Tagged<DOMException, TimeoutErrorName>;
54
43
  export declare function isTimeoutError(value: unknown): value is TimeoutError;
55
- //#endregion
56
- //#region src/classes/timed-out.d.ts
57
44
  export declare const TIMED_OUT_ERROR_CODE = "TIMED_OUT_ERROR";
58
45
  export type TimedOutErrorCode = typeof TIMED_OUT_ERROR_CODE;
59
46
  export declare class TimedOutError<TMeta extends BaseErrorMeta = null> extends BaseError<TimedOutErrorCode, TimeoutError, TMeta> {
60
47
  readonly name = "TimedOutError";
61
48
  readonly code = "TIMED_OUT_ERROR";
62
49
  }
63
- //#endregion
64
- //#region src/helpers/is/internal-error.d.ts
65
50
  export declare const INTERNAL_ERROR_NAME = "InternalError";
66
51
  export type InternalErrorName = typeof INTERNAL_ERROR_NAME;
67
52
  export interface InternalError extends Error {
68
53
  name: InternalErrorName;
69
54
  }
70
55
  export declare function isInternalError(value: unknown): value is InternalError;
71
- //#endregion
72
- //#region src/helpers/is/stack-overflow-error.d.ts
73
56
  export type StackOverflowErrorTag = "StackOverflowError";
74
57
  export type StackOverflowError = Tagged<RangeError | InternalError, StackOverflowErrorTag>;
75
58
  export declare function isStackOverflowError(value: unknown): value is StackOverflowError;
76
- //#endregion
77
- //#region src/classes/stack-overflowed.d.ts
78
59
  export declare const STACK_OVERFLOWED_ERROR_CODE = "STACK_OVERFLOWED_ERROR";
79
60
  export type StackOverflowedErrorCode = typeof STACK_OVERFLOWED_ERROR_CODE;
80
61
  export declare class StackOverflowedError<TMeta extends BaseErrorMeta = null> extends BaseError<StackOverflowedErrorCode, StackOverflowError, TMeta> {
81
62
  readonly name = "StackOverflowedError";
82
63
  readonly code = "STACK_OVERFLOWED_ERROR";
83
64
  }
84
- //#endregion
85
- //#region src/helpers/is/error.d.ts
86
65
  export declare function isError(value: unknown): value is Error;
87
- //#endregion
88
- //#region src/helpers/is/range-error.d.ts
89
66
  export declare function isRangeError(value: unknown): value is RangeError;
90
- //#endregion
91
- //#region src/helpers/is/aggregate-error.d.ts
92
67
  export declare function isAggregateError(error: Error): error is AggregateError;
93
- //#endregion
94
- //#region src/helpers/is/eval-error.d.ts
95
68
  export declare function isEvalError(error: Error): error is EvalError;
96
- //#endregion
97
- //#region src/helpers/is/reference-error.d.ts
98
69
  export declare function isReferenceError(error: Error): error is ReferenceError;
99
- //#endregion
100
- //#region src/helpers/is/syntax-error.d.ts
101
70
  export declare function isSyntaxError(error: Error): error is SyntaxError;
102
- //#endregion
103
- //#region src/helpers/is/type-error.d.ts
104
71
  export declare function isTypeError(error: Error): error is TypeError;
105
- //#endregion
106
- //#region src/helpers/is/uri-error.d.ts
107
72
  export declare function isUriError(error: Error): error is URIError;
108
- //#endregion
109
- //#region src/helpers/compose-error-message.d.ts
110
- export declare const DEFAULT_FAILURE_REASON = "some unexpected error";
111
- export declare function composeErrorMessage<TOperation extends string, TReason extends string>({ operation, reason }: {
112
- operation: TOperation;
113
- reason: TReason;
114
- }): `Failed to ${TOperation} due to ${TReason}.`;
115
- //#endregion
73
+ export declare const DEFAULT_FAILURE_REASON = "some unknown exception";
74
+ export declare function composeErrorMessage({ operation, reason }: {
75
+ operation: string;
76
+ reason?: string;
77
+ }): string;
116
78
  export type { BaseErrorMeta, BaseErrorType };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/classes/base.ts
1
+ // src/classes/base.ts
2
2
  var BaseError = class extends Error {
3
3
  meta;
4
4
  constructor({ message, cause, meta }) {
@@ -6,43 +6,37 @@ var BaseError = class extends Error {
6
6
  this.meta = meta;
7
7
  }
8
8
  };
9
- //#endregion
10
- //#region src/classes/unexpected.ts
9
+ // src/classes/unexpected.ts
11
10
  const UNEXPECTED_ERROR_CODE = "UNEXPECTED_ERROR";
12
11
  var UnexpectedError = class extends BaseError {
13
12
  name = "UnexpectedError";
14
13
  code = UNEXPECTED_ERROR_CODE;
15
14
  };
16
- //#endregion
17
- //#region src/classes/aborted.ts
15
+ // src/classes/aborted.ts
18
16
  const ABORTED_ERROR_CODE = "ABORTED_ERROR";
19
17
  var AbortedError = class extends BaseError {
20
18
  name = "AbortedError";
21
19
  code = ABORTED_ERROR_CODE;
22
20
  };
23
- //#endregion
24
- //#region src/classes/timed-out.ts
21
+ // src/classes/timed-out.ts
25
22
  const TIMED_OUT_ERROR_CODE = "TIMED_OUT_ERROR";
26
23
  var TimedOutError = class extends BaseError {
27
24
  name = "TimedOutError";
28
25
  code = TIMED_OUT_ERROR_CODE;
29
26
  };
30
- //#endregion
31
- //#region src/classes/stack-overflowed.ts
27
+ // src/classes/stack-overflowed.ts
32
28
  const STACK_OVERFLOWED_ERROR_CODE = "STACK_OVERFLOWED_ERROR";
33
29
  var StackOverflowedError = class extends BaseError {
34
30
  name = "StackOverflowedError";
35
31
  code = STACK_OVERFLOWED_ERROR_CODE;
36
32
  };
37
- //#endregion
38
- //#region src/helpers/is/error.ts
33
+ // src/helpers/is/error.ts
39
34
  function isError(value) {
40
35
  if (Object.hasOwn(Error, "isError") && Error.isError(value)) return true;
41
36
  if (value instanceof Error) return true;
42
37
  return false;
43
38
  }
44
- //#endregion
45
- //#region src/helpers/is/abort-error.ts
39
+ // src/helpers/is/abort-error.ts
46
40
  const ABORT_ERROR_NAME = "AbortError";
47
41
  const ABORT_ERROR_CODE = "ABORT_ERR";
48
42
  function isAbortError(value) {
@@ -52,68 +46,56 @@ function isAbortError(value) {
52
46
  }
53
47
  return false;
54
48
  }
55
- //#endregion
56
- //#region src/helpers/is/timeout-error.ts
49
+ // src/helpers/is/timeout-error.ts
57
50
  const TIMEOUT_ERROR_NAME = "TimeoutError";
58
51
  function isTimeoutError(value) {
59
52
  if (value instanceof DOMException && value.name === "TimeoutError") return true;
60
53
  return false;
61
54
  }
62
- //#endregion
63
- //#region src/helpers/is/range-error.ts
55
+ // src/helpers/is/range-error.ts
64
56
  function isRangeError(value) {
65
57
  if (isError(value) && value.name === RangeError.name) return true;
66
58
  if (value instanceof RangeError) return true;
67
59
  return false;
68
60
  }
69
- //#endregion
70
- //#region src/helpers/is/internal-error.ts
61
+ // src/helpers/is/internal-error.ts
71
62
  const INTERNAL_ERROR_NAME = "InternalError";
72
63
  function isInternalError(value) {
73
64
  return isError(value) && value.name === "InternalError";
74
65
  }
75
- //#endregion
76
- //#region src/helpers/is/stack-overflow-error.ts
66
+ // src/helpers/is/stack-overflow-error.ts
77
67
  function isStackOverflowError(value) {
78
68
  if (isRangeError(value) && value.message.includes("call stack size exceeded")) return true;
79
69
  if (isInternalError(value) && value.message.includes("too much recursion")) return true;
80
70
  return false;
81
71
  }
82
- //#endregion
83
- //#region src/helpers/is/aggregate-error.ts
72
+ // src/helpers/is/aggregate-error.ts
84
73
  function isAggregateError(error) {
85
74
  return error.name === AggregateError.name;
86
75
  }
87
- //#endregion
88
- //#region src/helpers/is/eval-error.ts
76
+ // src/helpers/is/eval-error.ts
89
77
  function isEvalError(error) {
90
78
  return error.name === EvalError.name;
91
79
  }
92
- //#endregion
93
- //#region src/helpers/is/reference-error.ts
80
+ // src/helpers/is/reference-error.ts
94
81
  function isReferenceError(error) {
95
82
  return error.name === ReferenceError.name;
96
83
  }
97
- //#endregion
98
- //#region src/helpers/is/syntax-error.ts
84
+ // src/helpers/is/syntax-error.ts
99
85
  function isSyntaxError(error) {
100
86
  return error.name === SyntaxError.name;
101
87
  }
102
- //#endregion
103
- //#region src/helpers/is/type-error.ts
88
+ // src/helpers/is/type-error.ts
104
89
  function isTypeError(error) {
105
90
  return error.name === TypeError.name;
106
91
  }
107
- //#endregion
108
- //#region src/helpers/is/uri-error.ts
92
+ // src/helpers/is/uri-error.ts
109
93
  function isUriError(error) {
110
94
  return error.name === URIError.name;
111
95
  }
112
- //#endregion
113
- //#region src/helpers/compose-error-message.ts
114
- const DEFAULT_FAILURE_REASON = "some unexpected error";
115
- function composeErrorMessage({ operation, reason }) {
96
+ // src/helpers/compose-error-message.ts
97
+ const DEFAULT_FAILURE_REASON = "some unknown exception";
98
+ function composeErrorMessage({ operation, reason = DEFAULT_FAILURE_REASON }) {
116
99
  return `Failed to ${operation} due to ${reason}.`;
117
100
  }
118
- //#endregion
119
101
  export { ABORTED_ERROR_CODE, ABORT_ERROR_CODE, ABORT_ERROR_NAME, AbortedError, BaseError, DEFAULT_FAILURE_REASON, INTERNAL_ERROR_NAME, STACK_OVERFLOWED_ERROR_CODE, StackOverflowedError, TIMED_OUT_ERROR_CODE, TIMEOUT_ERROR_NAME, TimedOutError, UNEXPECTED_ERROR_CODE, UnexpectedError, composeErrorMessage, isAbortError, isAggregateError, isError, isEvalError, isInternalError, isRangeError, isReferenceError, isStackOverflowError, isSyntaxError, isTimeoutError, isTypeError, isUriError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@little-nebulae/error",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"
@@ -17,16 +17,16 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@arethetypeswrong/core": "0.18.5",
20
- "@types/node": "26.6.4",
21
- "oxfmt": "0.72.0",
22
- "oxlint": "1.87.0",
23
- "oxlint-tsgolint": "7.0.2003",
20
+ "@oxc-node/cli": "1.0.1",
21
+ "@types/node": "26.6.6",
22
+ "oxfmt": "0.75.0",
23
+ "oxlint": "1.90.0",
24
+ "oxlint-tsgolint": "7.0.2005",
24
25
  "publint": "0.3.25",
25
- "tsdown": "0.23.0",
26
- "tsx": "4.23.15",
26
+ "tsdown": "0.23.2",
27
27
  "type-fest": "5.10.0",
28
- "typescript": "7.0.2",
29
- "vitest": "5.0.3"
28
+ "typescript": "7.1.0-beta",
29
+ "vitest": "5.0.5"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "type-fest": "^5.0.0"
@@ -34,13 +34,13 @@
34
34
  "devEngines": {
35
35
  "packageManager": {
36
36
  "name": "pnpm",
37
- "version": "12.9.1",
37
+ "version": "12.16.1",
38
38
  "onFail": "warn"
39
39
  }
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsdown",
43
- "try": "tsx src/try.ts",
43
+ "try": "oxnode ./src/try.ts",
44
44
  "fmt": "oxfmt --disable-nested-config",
45
45
  "fmt:check": "oxfmt --check --disable-nested-config",
46
46
  "lint": "oxlint --disable-nested-config",