-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexception-json.ts
50 lines (44 loc) · 1.14 KB
/
exception-json.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @file Interfaces - ExceptionJSON
* @module exceptions/interfaces/ExceptionJSON
*/
import type { Errors } from '#src/types'
import type {
JsonifiableObject,
Nullable,
ObjectPlain
} from '@flex-development/tutils'
/**
* JSON representation of an `Exception`.
*
* @template T - Aggregated error type
* @template Data - Exception data type
* @template Cause - Exception cause type
* @template Code - Exception code type
*/
interface ExceptionJSON<
T extends ObjectPlain = JsonifiableObject,
Data extends ObjectPlain = JsonifiableObject,
Cause extends ObjectPlain = JsonifiableObject,
Code extends Nullable<number | string> = string
> {
/**
* Specific cause of the exception.
*
* @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error/cause#providing_structured_data_as_the_error_cause
*/
readonly cause: Readonly<Cause & { code: Code }>
/**
* Custom exception data.
*/
readonly data: Data
/**
* Aggregated errors.
*/
readonly errors: Errors<T> | Readonly<Errors<T>>
/**
* Exception message.
*/
readonly message: string
}
export type { ExceptionJSON as default }