@creejs/commons-lang 2.1.20 → 2.1.21

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.
@@ -0,0 +1,30 @@
1
+ export default class _Error extends Error {
2
+ /**
3
+ * Creates and returns a 404 Not Found error instance with the given message.
4
+ * @param {string} message - The error message to include.
5
+ * @returns {_Error} A new Error instance with status code 404.
6
+ */
7
+ static notFound(message: string): _Error;
8
+ static notImpled(): _Error;
9
+ /**
10
+ * Creates and returns a new Error instance for not supported operations.
11
+ * @param {string} message - The error message to include.
12
+ * @returns {_Error} A new Error instance with "Not Supported:" prefix and 505 status code.
13
+ */
14
+ static notSupported(message: string): _Error;
15
+ /**
16
+ * Checks if the given error is a "Not Supported" error.
17
+ * @param {Error|_Error|{[key:string]:any}|unknown} err - The error to check
18
+ * @returns {boolean} True if the error is a Not Supported error (code 505), false otherwise
19
+ */
20
+ static isNotSupported(err: Error | _Error | {
21
+ [key: string]: any;
22
+ } | unknown): boolean;
23
+ /**
24
+ * Error constructor with custom message and code.
25
+ * @param {string} message - Error message
26
+ * @param {number|string} code - Error code
27
+ */
28
+ constructor(message: string, code: number | string);
29
+ code: string | number;
30
+ }
@@ -0,0 +1,34 @@
1
+ export default class AggregatedError extends Error {
2
+ /**
3
+ * Checks if the given error is an AggregatedErrorLike
4
+ * 1. have "message:string" property
5
+ * 2. have "errors:Error[]" property
6
+ * @param {any} err - The error to check
7
+ * @returns {boolean} True if the error is an AggregatedError, false otherwise
8
+ */
9
+ static isAggregatedErrorLike(err: any): boolean;
10
+ /**
11
+ * Checks if the given error is an instance of AggregatedError.
12
+ * @param {Error} err - The error to check.
13
+ * @returns {boolean} True if the error is an AggregatedError, false otherwise.
14
+ */
15
+ static isAggregatedError(err: Error): boolean;
16
+ /**
17
+ * Error constructor with custom message and code.
18
+ * @param {string} message - Error message
19
+ * @param {any[]} [errors] - Errors
20
+ */
21
+ constructor(message: string, errors?: any[]);
22
+ errors: any[];
23
+ /**
24
+ * Adds an error to the errors collection.
25
+ * @param {any} err - The error object to be added.
26
+ */
27
+ addError(err: any): void;
28
+ /**
29
+ * Removes a specific error from the errors array.
30
+ * @param {Error} err - The error instance to remove.
31
+ * @returns {boolean} True if the error was found and removed, false otherwise.
32
+ */
33
+ removeError(err: Error): boolean;
34
+ }
package/types/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  declare namespace _default {
2
+ export { _Error };
3
+ export { AggregatedError };
2
4
  export { LangUtils };
3
5
  export { StringUtils };
4
6
  export { TypeUtils };
@@ -17,6 +19,8 @@ declare namespace _default {
17
19
  export { ArrayUtils };
18
20
  }
19
21
  export default _default;
22
+ import _Error from './_error.js';
23
+ import AggregatedError from './aggregated-error.js';
20
24
  import LangUtils from './lang-utils.js';
21
25
  import StringUtils from './string-utils.js';
22
26
  import TypeUtils from './type-utils.js';
@@ -30,4 +34,4 @@ import TypedArrayUtils from './typed-array-utils.js';
30
34
  import ArrayBufferUtils from './array-buffer-utils.js';
31
35
  import TimeUtils from './time-utils.js';
32
36
  import ArrayUtils from './array-utils.js';
33
- export { LangUtils, StringUtils, TypeUtils, TypeAssert, ExecUtils, PromiseUtils, LangUtils as Lang, TypeUtils as Type, ExecUtils as Exec, ClassProxyUtils, InstanceProxyUtils, ReflectUtils, TypedArrayUtils, ArrayBufferUtils, TimeUtils, ArrayUtils };
37
+ export { _Error, AggregatedError, LangUtils, StringUtils, TypeUtils, TypeAssert, ExecUtils, PromiseUtils, LangUtils as Lang, TypeUtils as Type, ExecUtils as Exec, ClassProxyUtils, InstanceProxyUtils, ReflectUtils, TypedArrayUtils, ArrayBufferUtils, TimeUtils, ArrayUtils };