@@ -7,12 +7,16 @@ import { MIMES } from './utils'
77 * @extends Error
88 * @property {Number } statusCode An Integer indicating the HTTP response status code.
99 * @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.
1012 * @property {Any } data An extra data that will includes in the response.<br>
1113 * This can be used to pass additional information about the error.
1214 * @property {Boolean } internal Setting this property to <code>true</code> will mark error as an internal error
1315 */
1416export class H3Error extends Error {
1517 statusCode : number = 500
18+ fatal : boolean = false
19+ unhandled : boolean = false
1620 statusMessage : string = 'Internal Server Error'
1721 data ?: any
1822}
@@ -34,17 +38,11 @@ export function createError (input: string | Partial<H3Error>): H3Error {
3438
3539 const err = new H3Error ( input . message ?? input . statusMessage , input . cause ? { cause : input . cause } : undefined )
3640
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 }
4846
4947 return err
5048}
0 commit comments