@@ -7,12 +7,16 @@ import { MIMES } from './utils'
7
7
* @extends Error
8
8
* @property {Number } statusCode An Integer indicating the HTTP response status code.
9
9
* @property {String } statusMessage A String representing the HTTP status message
10
+ * @property {String } fatal Indicates if the error is a fatal error.
11
+ * @property {String } unhandled Indicates if the error was unhandled and auto captured.
10
12
* @property {Any } data An extra data that will includes in the response.<br>
11
13
* This can be used to pass additional information about the error.
12
14
* @property {Boolean } internal Setting this property to <code>true</code> will mark error as an internal error
13
15
*/
14
16
export class H3Error extends Error {
15
17
statusCode : number = 500
18
+ fatal : boolean = false
19
+ unhandled : boolean = false
16
20
statusMessage : string = 'Internal Server Error'
17
21
data ?: any
18
22
}
@@ -34,17 +38,11 @@ export function createError (input: string | Partial<H3Error>): H3Error {
34
38
35
39
const err = new H3Error ( input . message ?? input . statusMessage , input . cause ? { cause : input . cause } : undefined )
36
40
37
- if ( input . statusCode ) {
38
- err . statusCode = input . statusCode
39
- }
40
-
41
- if ( input . statusMessage ) {
42
- err . statusMessage = input . statusMessage
43
- }
44
-
45
- if ( input . data ) {
46
- err . data = input . data
47
- }
41
+ if ( input . statusCode ) { err . statusCode = input . statusCode }
42
+ if ( input . statusMessage ) { err . statusMessage = input . statusMessage }
43
+ if ( input . data ) { err . data = input . data }
44
+ if ( input . fatal !== undefined ) { err . fatal = input . fatal }
45
+ if ( input . unhandled !== undefined ) { err . unhandled = input . unhandled }
48
46
49
47
return err
50
48
}
0 commit comments