@travetto/runtime 5.0.12 → 5.0.13
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/package.json +1 -1
- package/src/error.ts +3 -1
package/package.json
CHANGED
package/src/error.ts
CHANGED
|
@@ -25,6 +25,8 @@ export type AppErrorOptions<T> =
|
|
|
25
25
|
*/
|
|
26
26
|
export class AppError<T = Record<string, unknown> | undefined> extends Error {
|
|
27
27
|
|
|
28
|
+
static defaultCategory?: ErrorCategory;
|
|
29
|
+
|
|
28
30
|
/** Convert from JSON object */
|
|
29
31
|
static fromJSON(e: unknown): AppError | undefined {
|
|
30
32
|
if (!!e && typeof e === 'object' &&
|
|
@@ -54,7 +56,7 @@ export class AppError<T = Record<string, unknown> | undefined> extends Error {
|
|
|
54
56
|
super(message, opts?.cause ? { cause: opts.cause } : undefined);
|
|
55
57
|
this.type = opts?.type ?? this.constructor.name;
|
|
56
58
|
this.details = opts?.details!;
|
|
57
|
-
this.category = opts?.category ?? 'general';
|
|
59
|
+
this.category = opts?.category ?? castTo<typeof AppError>(this.constructor).defaultCategory ?? 'general';
|
|
58
60
|
this.at = new Date(opts?.at ?? Date.now()).toISOString();
|
|
59
61
|
}
|
|
60
62
|
|