@jakubmazanec/error 2.0.1-9029e49 → 2.0.1-bc209e5
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 +3 -1
- package/dist/createCustomError.d.ts +1 -1
- package/dist/createCustomError.js +4 -3
- package/dist/createCustomError.js.map +1 -1
- package/dist/createCustomErrorWithData.d.ts +1 -1
- package/dist/createCustomErrorWithData.js +4 -3
- package/dist/createCustomErrorWithData.js.map +1 -1
- package/dist/internals/createErrorMessage.js.map +1 -1
- package/dist/types/CustomErrorOptions.d.ts +1 -1
- package/dist/types/CustomErrorOptions.js +1 -1
- package/dist/types/CustomErrorOptions.js.map +1 -1
- package/dist/types/CustomErrorWithDataOptions.d.ts +1 -1
- package/dist/types/CustomErrorWithDataOptions.js +1 -1
- package/dist/types/CustomErrorWithDataOptions.js.map +1 -1
- package/package.json +1 -1
- package/src/createCustomError.ts +1 -1
- package/src/createCustomErrorWithData.ts +1 -1
- package/src/types/CustomErrorOptions.ts +1 -1
- package/src/types/CustomErrorWithDataOptions.ts +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
<!-- header -->
|
|
1
2
|
<div align="center">
|
|
2
3
|
|
|
3
4
|
# @jakubmazanec/error
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Collection of utilities for creating and handling errors.
|
|
6
7
|
|
|
7
8
|
</div>
|
|
9
|
+
<!-- header -->
|
|
8
10
|
|
|
9
11
|
## Installation
|
|
10
12
|
|
|
@@ -6,6 +6,6 @@ import { type CustomError, type CustomErrorOptions, type ErrorMessages } from '.
|
|
|
6
6
|
*
|
|
7
7
|
* @param errorName Error name.
|
|
8
8
|
* @param errorMessages Object containing all possible error messages.
|
|
9
|
-
* @return Class that implements {@
|
|
9
|
+
* @return Class that implements {@link CustomError}.
|
|
10
10
|
*/
|
|
11
11
|
export declare function createCustomError<ErrorCode extends string>(errorName: string, errorMessages: ErrorMessages<ErrorCode>): new (code: ErrorCode, options?: CustomErrorOptions) => CustomError<ErrorCode | typeof UNKNOWN_ERROR>;
|
|
@@ -6,14 +6,15 @@ import { createErrorMessage } from './internals.js';
|
|
|
6
6
|
*
|
|
7
7
|
* @param errorName Error name.
|
|
8
8
|
* @param errorMessages Object containing all possible error messages.
|
|
9
|
-
* @return Class that implements {@
|
|
9
|
+
* @return Class that implements {@link CustomError}.
|
|
10
10
|
*/ export function createCustomError(errorName, errorMessages) {
|
|
11
11
|
return class InternalCustomError extends Error {
|
|
12
12
|
code;
|
|
13
13
|
constructor(errorCode, options){
|
|
14
|
-
|
|
14
|
+
var _options, _options1;
|
|
15
|
+
let errorMessage = createErrorMessage(errorCode, errorMessages, (_options = options) === null || _options === void 0 ? void 0 : _options.messageParameters);
|
|
15
16
|
let errorOptions = {};
|
|
16
|
-
if (typeof (options === null ||
|
|
17
|
+
if (typeof ((_options1 = options) === null || _options1 === void 0 ? void 0 : _options1.cause) !== 'undefined') {
|
|
17
18
|
errorOptions.cause = options.cause;
|
|
18
19
|
}
|
|
19
20
|
super(errorMessage, errorOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createCustomError.ts"],"sourcesContent":["import {INTERNAL_ERROR_MESSAGES, UNKNOWN_ERROR} from './constants.js';\nimport {createErrorMessage} from './internals.js';\nimport {type CustomError, type CustomErrorOptions, type ErrorMessages} from './types.js';\n\n/**\n * Function for creating custom error classes. Such custom error class properly subclasses built-in `Error` and simplifies\n * generating error messages via predefined error codes.\n *\n * @param errorName Error name.\n * @param errorMessages Object containing all possible error messages.\n * @return Class that implements {@
|
|
1
|
+
{"version":3,"sources":["../src/createCustomError.ts"],"sourcesContent":["import {INTERNAL_ERROR_MESSAGES, UNKNOWN_ERROR} from './constants.js';\nimport {createErrorMessage} from './internals.js';\nimport {type CustomError, type CustomErrorOptions, type ErrorMessages} from './types.js';\n\n/**\n * Function for creating custom error classes. Such custom error class properly subclasses built-in `Error` and simplifies\n * generating error messages via predefined error codes.\n *\n * @param errorName Error name.\n * @param errorMessages Object containing all possible error messages.\n * @return Class that implements {@link CustomError}.\n */\nexport function createCustomError<ErrorCode extends string>(\n errorName: string,\n errorMessages: ErrorMessages<ErrorCode>,\n): new (code: ErrorCode, options?: CustomErrorOptions) => CustomError<\n ErrorCode | typeof UNKNOWN_ERROR\n> {\n return class InternalCustomError extends Error implements CustomError<ErrorCode> {\n code: ErrorCode | typeof UNKNOWN_ERROR;\n\n constructor(errorCode: ErrorCode, options?: CustomErrorOptions) {\n let errorMessage = createErrorMessage(errorCode, errorMessages, options?.messageParameters);\n let errorOptions: ErrorOptions = {};\n\n if (typeof options?.cause !== 'undefined') {\n errorOptions.cause = options.cause;\n }\n\n super(errorMessage, errorOptions);\n\n this.code = errorCode;\n this.name = errorName;\n\n // if the message is empty, we are making this an unknown error\n if (!this.message) {\n this.code = UNKNOWN_ERROR;\n this.message = createErrorMessage(UNKNOWN_ERROR, INTERNAL_ERROR_MESSAGES);\n }\n }\n };\n}\n"],"names":["INTERNAL_ERROR_MESSAGES","UNKNOWN_ERROR","createErrorMessage","createCustomError","errorName","errorMessages","InternalCustomError","Error","code","constructor","errorCode","options","errorMessage","messageParameters","errorOptions","cause","name","message"],"mappings":"AAAA,SAAQA,uBAAuB,EAAEC,aAAa,QAAO,iBAAiB;AACtE,SAAQC,kBAAkB,QAAO,iBAAiB;AAGlD;;;;;;;CAOC,GACD,OAAO,SAASC,kBACdC,SAAiB,EACjBC,aAAuC;IAIvC,OAAO,MAAMC,4BAA4BC;QACvCC,KAAuC;QAEvCC,YAAYC,SAAoB,EAAEC,OAA4B,CAAE;gBACEA,UAGrDA;YAHX,IAAIC,eAAeV,mBAAmBQ,WAAWL,gBAAeM,WAAAA,qBAAAA,+BAAAA,SAASE,iBAAiB;YAC1F,IAAIC,eAA6B,CAAC;YAElC,IAAI,SAAOH,YAAAA,qBAAAA,gCAAAA,UAASI,KAAK,MAAK,aAAa;gBACzCD,aAAaC,KAAK,GAAGJ,QAAQI,KAAK;YACpC;YAEA,KAAK,CAACH,cAAcE;YAEpB,IAAI,CAACN,IAAI,GAAGE;YACZ,IAAI,CAACM,IAAI,GAAGZ;YAEZ,+DAA+D;YAC/D,IAAI,CAAC,IAAI,CAACa,OAAO,EAAE;gBACjB,IAAI,CAACT,IAAI,GAAGP;gBACZ,IAAI,CAACgB,OAAO,GAAGf,mBAAmBD,eAAeD;YACnD;QACF;IACF;AACF"}
|
|
@@ -8,7 +8,7 @@ import { type CustomErrorWithData, type CustomErrorWithDataOptions, type ErrorMe
|
|
|
8
8
|
* @param errorName Error name.
|
|
9
9
|
* @param errorMessages Object containing all possible error messages.
|
|
10
10
|
* @param errorData Runtime representation of the `ErrorData` type parameter; can be either a class expression, or a Zod schema.
|
|
11
|
-
* @return Class that implements {@
|
|
11
|
+
* @return Class that implements {@link CustomErrorWithData}.
|
|
12
12
|
*/
|
|
13
13
|
export declare function createCustomErrorWithData<ErrorCode extends string, ErrorData extends AnyZodObject>(errorName: string, errorMessages: ErrorMessages<ErrorCode>, errorData: ErrorData): new (code: ErrorCode, options?: CustomErrorWithDataOptions<z.infer<ErrorData>>) => CustomErrorWithData<ErrorCode | typeof UNKNOWN_ERROR, z.infer<ErrorData>>;
|
|
14
14
|
export declare function createCustomErrorWithData<ErrorCode extends string, ErrorData extends abstract new (...args: any) => any>(errorName: string, errorMessages: ErrorMessages<ErrorCode>, errorData: ErrorData): new (code: ErrorCode, options?: CustomErrorWithDataOptions<InstanceType<ErrorData>>) => CustomErrorWithData<ErrorCode | typeof UNKNOWN_ERROR, InstanceType<ErrorData>>;
|
|
@@ -5,15 +5,16 @@ export function createCustomErrorWithData(errorName, errorMessages, errorData) {
|
|
|
5
5
|
code;
|
|
6
6
|
data;
|
|
7
7
|
constructor(errorCode, options){
|
|
8
|
-
|
|
8
|
+
var _options, _options1, _options2;
|
|
9
|
+
let errorMessage = createErrorMessage(errorCode, errorMessages, (_options = options) === null || _options === void 0 ? void 0 : _options.messageParameters);
|
|
9
10
|
let errorOptions = {};
|
|
10
|
-
if (typeof (options === null ||
|
|
11
|
+
if (typeof ((_options1 = options) === null || _options1 === void 0 ? void 0 : _options1.cause) !== 'undefined') {
|
|
11
12
|
errorOptions.cause = options.cause;
|
|
12
13
|
}
|
|
13
14
|
super(errorMessage, errorOptions);
|
|
14
15
|
this.code = errorCode;
|
|
15
16
|
this.name = errorName;
|
|
16
|
-
if (typeof (options === null ||
|
|
17
|
+
if (typeof ((_options2 = options) === null || _options2 === void 0 ? void 0 : _options2.data) !== 'undefined') {
|
|
17
18
|
this.data = options.data;
|
|
18
19
|
}
|
|
19
20
|
// if the message is empty, we are making this an unknown error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createCustomErrorWithData.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- needed */\nimport {type z, type AnyZodObject} from 'zod';\n\nimport {INTERNAL_ERROR_MESSAGES, UNKNOWN_ERROR} from './constants.js';\nimport {createErrorMessage} from './internals.js';\nimport {\n type CustomErrorWithData,\n type CustomErrorWithDataOptions,\n type ErrorMessages,\n} from './types.js';\n\n/**\n * Function for creating custom error classes. Such custom error class properly subclasses built-in `Error`, simplifies\n * generating error messages via predefined error codes and allows attaching custom data to the error instance.\n *\n * @param errorName Error name.\n * @param errorMessages Object containing all possible error messages.\n * @param errorData Runtime representation of the `ErrorData` type parameter; can be either a class expression, or a Zod schema.\n * @return Class that implements {@
|
|
1
|
+
{"version":3,"sources":["../src/createCustomErrorWithData.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any -- needed */\nimport {type z, type AnyZodObject} from 'zod';\n\nimport {INTERNAL_ERROR_MESSAGES, UNKNOWN_ERROR} from './constants.js';\nimport {createErrorMessage} from './internals.js';\nimport {\n type CustomErrorWithData,\n type CustomErrorWithDataOptions,\n type ErrorMessages,\n} from './types.js';\n\n/**\n * Function for creating custom error classes. Such custom error class properly subclasses built-in `Error`, simplifies\n * generating error messages via predefined error codes and allows attaching custom data to the error instance.\n *\n * @param errorName Error name.\n * @param errorMessages Object containing all possible error messages.\n * @param errorData Runtime representation of the `ErrorData` type parameter; can be either a class expression, or a Zod schema.\n * @return Class that implements {@link CustomErrorWithData}.\n */\nexport function createCustomErrorWithData<ErrorCode extends string, ErrorData extends AnyZodObject>(\n errorName: string,\n errorMessages: ErrorMessages<ErrorCode>,\n errorData: ErrorData,\n): new (\n code: ErrorCode,\n options?: CustomErrorWithDataOptions<z.infer<ErrorData>>,\n) => CustomErrorWithData<ErrorCode | typeof UNKNOWN_ERROR, z.infer<ErrorData>>;\nexport function createCustomErrorWithData<\n ErrorCode extends string,\n ErrorData extends abstract new (...args: any) => any,\n>(\n errorName: string,\n errorMessages: ErrorMessages<ErrorCode>,\n errorData: ErrorData,\n): new (\n code: ErrorCode,\n options?: CustomErrorWithDataOptions<InstanceType<ErrorData>>,\n) => CustomErrorWithData<ErrorCode | typeof UNKNOWN_ERROR, InstanceType<ErrorData>>;\nexport function createCustomErrorWithData<ErrorCode extends string, ErrorData>(\n errorName: string,\n errorMessages: ErrorMessages<ErrorCode>,\n errorData: ErrorData,\n): new (code: ErrorCode, options?: CustomErrorWithDataOptions<ErrorData>) => CustomErrorWithData<\n ErrorCode | typeof UNKNOWN_ERROR,\n ErrorData\n> {\n return class InternalCustomError\n extends Error\n implements CustomErrorWithData<ErrorCode, ErrorData>\n {\n code: ErrorCode | typeof UNKNOWN_ERROR;\n data?: ErrorData;\n\n constructor(errorCode: ErrorCode, options?: CustomErrorWithDataOptions<ErrorData>) {\n let errorMessage = createErrorMessage(errorCode, errorMessages, options?.messageParameters);\n let errorOptions: ErrorOptions = {};\n\n if (typeof options?.cause !== 'undefined') {\n errorOptions.cause = options.cause;\n }\n\n super(errorMessage, errorOptions);\n\n this.code = errorCode;\n this.name = errorName;\n\n if (typeof options?.data !== 'undefined') {\n this.data = options.data;\n }\n\n // if the message is empty, we are making this an unknown error\n if (!this.message) {\n this.code = UNKNOWN_ERROR;\n this.message = createErrorMessage(UNKNOWN_ERROR, INTERNAL_ERROR_MESSAGES);\n }\n }\n };\n}\n"],"names":["INTERNAL_ERROR_MESSAGES","UNKNOWN_ERROR","createErrorMessage","createCustomErrorWithData","errorName","errorMessages","errorData","InternalCustomError","Error","code","data","constructor","errorCode","options","errorMessage","messageParameters","errorOptions","cause","name","message"],"mappings":"AAAA,+DAA+D,GAG/D,SAAQA,uBAAuB,EAAEC,aAAa,QAAO,iBAAiB;AACtE,SAAQC,kBAAkB,QAAO,iBAAiB;AAmClD,OAAO,SAASC,0BACdC,SAAiB,EACjBC,aAAuC,EACvCC,SAAoB;IAKpB,OAAO,MAAMC,4BACHC;QAGRC,KAAuC;QACvCC,KAAiB;QAEjBC,YAAYC,SAAoB,EAAEC,OAA+C,CAAE;gBACjBA,UAGrDA,WASAA;YAZX,IAAIC,eAAeZ,mBAAmBU,WAAWP,gBAAeQ,WAAAA,qBAAAA,+BAAAA,SAASE,iBAAiB;YAC1F,IAAIC,eAA6B,CAAC;YAElC,IAAI,SAAOH,YAAAA,qBAAAA,gCAAAA,UAASI,KAAK,MAAK,aAAa;gBACzCD,aAAaC,KAAK,GAAGJ,QAAQI,KAAK;YACpC;YAEA,KAAK,CAACH,cAAcE;YAEpB,IAAI,CAACP,IAAI,GAAGG;YACZ,IAAI,CAACM,IAAI,GAAGd;YAEZ,IAAI,SAAOS,YAAAA,qBAAAA,gCAAAA,UAASH,IAAI,MAAK,aAAa;gBACxC,IAAI,CAACA,IAAI,GAAGG,QAAQH,IAAI;YAC1B;YAEA,+DAA+D;YAC/D,IAAI,CAAC,IAAI,CAACS,OAAO,EAAE;gBACjB,IAAI,CAACV,IAAI,GAAGR;gBACZ,IAAI,CAACkB,OAAO,GAAGjB,mBAAmBD,eAAeD;YACnD;QACF;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/internals/createErrorMessage.ts"],"sourcesContent":["import {ERROR_MESSAGE_TOKEN_PATTERN} from '../constants.js';\nimport {type ErrorMessages} from '../types.js';\n\n/**\n * A function that generates an error message based on provided error code and message parameters. It is used only internally.\n *\n * @param errorCode Error code.\n * @param errorMessages Object containing all possible error messages.\n * @param messageParameters Array of values that are used as message parameters.\n * @return Error message.\n */\nexport function createErrorMessage<T extends string>(\n errorCode: T,\n errorMessages: ErrorMessages<T>,\n messageParameters: unknown[] = [],\n): string {\n let errorMessage = errorMessages[errorCode];\n\n if (!errorMessage) {\n return '';\n }\n\n return `${errorCode}: ${errorMessage.replace(\n ERROR_MESSAGE_TOKEN_PATTERN,\n (match: string, index: number) => String(messageParameters[index]),\n )}`;\n}\n"],"names":["ERROR_MESSAGE_TOKEN_PATTERN","createErrorMessage","errorCode","errorMessages","messageParameters","errorMessage","replace","match","index","String"],"mappings":"AAAA,SAAQA,2BAA2B,QAAO,kBAAkB;AAG5D;;;;;;;CAOC,GACD,OAAO,SAASC,mBACdC,SAAY,EACZC,aAA+B,EAC/BC,oBAA+B,EAAE;IAEjC,IAAIC,eAAeF,aAAa,CAACD,UAAU;IAE3C,IAAI,CAACG,cAAc;QACjB,OAAO;IACT;IAEA,OAAO,CAAC,EAAEH,UAAU,EAAE,EAAEG,aAAaC,
|
|
1
|
+
{"version":3,"sources":["../../src/internals/createErrorMessage.ts"],"sourcesContent":["import {ERROR_MESSAGE_TOKEN_PATTERN} from '../constants.js';\nimport {type ErrorMessages} from '../types.js';\n\n/**\n * A function that generates an error message based on provided error code and message parameters. It is used only internally.\n *\n * @param errorCode Error code.\n * @param errorMessages Object containing all possible error messages.\n * @param messageParameters Array of values that are used as message parameters.\n * @return Error message.\n */\nexport function createErrorMessage<T extends string>(\n errorCode: T,\n errorMessages: ErrorMessages<T>,\n messageParameters: unknown[] = [],\n): string {\n let errorMessage = errorMessages[errorCode];\n\n if (!errorMessage) {\n return '';\n }\n\n return `${errorCode}: ${errorMessage.replace(\n ERROR_MESSAGE_TOKEN_PATTERN,\n (match: string, index: number) => String(messageParameters[index]),\n )}`;\n}\n"],"names":["ERROR_MESSAGE_TOKEN_PATTERN","createErrorMessage","errorCode","errorMessages","messageParameters","errorMessage","replace","match","index","String"],"mappings":"AAAA,SAAQA,2BAA2B,QAAO,kBAAkB;AAG5D;;;;;;;CAOC,GACD,OAAO,SAASC,mBACdC,SAAY,EACZC,aAA+B,EAC/BC,oBAA+B,EAAE;IAEjC,IAAIC,eAAeF,aAAa,CAACD,UAAU;IAE3C,IAAI,CAACG,cAAc;QACjB,OAAO;IACT;IAEA,OAAO,CAAC,EAAEH,UAAU,EAAE,EAAEG,aAAaC,OAAO,CAC1CN,6BACA,CAACO,OAAeC,QAAkBC,OAAOL,iBAAiB,CAACI,MAAM,GACjE,CAAC;AACL"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type representing options object used when instantianting class returned from {@
|
|
2
|
+
* Type representing options object used when instantianting class returned from {@link createCustomError}.
|
|
3
3
|
*/
|
|
4
4
|
export type CustomErrorOptions = {
|
|
5
5
|
/** Array of values that are used as parameters to generate the error message. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type representing options object used when instantianting class returned from {@
|
|
2
|
+
* Type representing options object used when instantianting class returned from {@link createCustomError}.
|
|
3
3
|
*/ export { };
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=CustomErrorOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/CustomErrorOptions.ts"],"sourcesContent":["/**\n * Type representing options object used when instantianting class returned from {@
|
|
1
|
+
{"version":3,"sources":["../../src/types/CustomErrorOptions.ts"],"sourcesContent":["/**\n * Type representing options object used when instantianting class returned from {@link createCustomError}.\n */\nexport type CustomErrorOptions = {\n /** Array of values that are used as parameters to generate the error message. */\n messageParameters?: unknown[];\n\n /** Used for setting `cause` property of an error instance that indicates the specific original cause of the error. */\n cause?: unknown;\n};\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WAME"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type representing options object used when instantianting class returned from {@
|
|
2
|
+
* Type representing options object used when instantianting class returned from {@link createCustomErrorWithData}.
|
|
3
3
|
*/
|
|
4
4
|
export type CustomErrorWithDataOptions<ErrorData> = {
|
|
5
5
|
/** Array of values that are used as parameters to generate the error message. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type representing options object used when instantianting class returned from {@
|
|
2
|
+
* Type representing options object used when instantianting class returned from {@link createCustomErrorWithData}.
|
|
3
3
|
*/ export { };
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=CustomErrorWithDataOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/CustomErrorWithDataOptions.ts"],"sourcesContent":["/**\n * Type representing options object used when instantianting class returned from {@
|
|
1
|
+
{"version":3,"sources":["../../src/types/CustomErrorWithDataOptions.ts"],"sourcesContent":["/**\n * Type representing options object used when instantianting class returned from {@link createCustomErrorWithData}.\n */\nexport type CustomErrorWithDataOptions<ErrorData> = {\n /** Array of values that are used as parameters to generate the error message. */\n messageParameters?: unknown[];\n\n /** Used for setting `cause` property of an error instance that indicates the specific original cause of the error. */\n cause?: unknown;\n\n /** Custom data that will be attached to the error instance. */\n data?: ErrorData;\n};\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WASE"}
|
package/package.json
CHANGED
package/src/createCustomError.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {type CustomError, type CustomErrorOptions, type ErrorMessages} from './t
|
|
|
8
8
|
*
|
|
9
9
|
* @param errorName Error name.
|
|
10
10
|
* @param errorMessages Object containing all possible error messages.
|
|
11
|
-
* @return Class that implements {@
|
|
11
|
+
* @return Class that implements {@link CustomError}.
|
|
12
12
|
*/
|
|
13
13
|
export function createCustomError<ErrorCode extends string>(
|
|
14
14
|
errorName: string,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
* @param errorName Error name.
|
|
17
17
|
* @param errorMessages Object containing all possible error messages.
|
|
18
18
|
* @param errorData Runtime representation of the `ErrorData` type parameter; can be either a class expression, or a Zod schema.
|
|
19
|
-
* @return Class that implements {@
|
|
19
|
+
* @return Class that implements {@link CustomErrorWithData}.
|
|
20
20
|
*/
|
|
21
21
|
export function createCustomErrorWithData<ErrorCode extends string, ErrorData extends AnyZodObject>(
|
|
22
22
|
errorName: string,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type representing options object used when instantianting class returned from {@
|
|
2
|
+
* Type representing options object used when instantianting class returned from {@link createCustomError}.
|
|
3
3
|
*/
|
|
4
4
|
export type CustomErrorOptions = {
|
|
5
5
|
/** Array of values that are used as parameters to generate the error message. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Type representing options object used when instantianting class returned from {@
|
|
2
|
+
* Type representing options object used when instantianting class returned from {@link createCustomErrorWithData}.
|
|
3
3
|
*/
|
|
4
4
|
export type CustomErrorWithDataOptions<ErrorData> = {
|
|
5
5
|
/** Array of values that are used as parameters to generate the error message. */
|