11import statusCodes , { getReasonPhrase } from 'http-status-codes' ;
22
3- import { BaseError } from './base .error' ;
3+ import { ApplicationError } from './application .error' ;
44import { ErrorOptions } from './types' ;
55
66export type HttpErrorOptions = ErrorOptions & {
@@ -20,8 +20,7 @@ export type HttpErrorOptions = ErrorOptions & {
2020 isHandled ?: boolean ;
2121} ;
2222
23- export class HttpError extends BaseError {
24-
23+ export class HttpError extends ApplicationError {
2524 /**
2625 * HTTP status regarding the error
2726 */
@@ -38,11 +37,15 @@ export class HttpError extends BaseError {
3837 public readonly isHandled ?: boolean ;
3938
4039 constructor ( message ?: string , error ?: Error , opts ?: HttpErrorOptions ) {
40+ // initialize null/undefined properties
41+ const _message = message || HttpError . name ;
42+
4143 /* Initialization phase */
42- super ( message , error , opts ) ;
44+ super ( _message , error , opts ) ;
4345
4446 this . statusCode = opts ?. statusCode || statusCodes . INTERNAL_SERVER_ERROR ;
45- this . statusMessage = opts ?. statusMessage || getReasonPhrase ( this . statusCode ) ;
47+ this . statusMessage =
48+ opts ?. statusMessage || getReasonPhrase ( this . statusCode ) ;
4649 this . isHandled = opts ?. isHandled || false ;
4750
4851 // set stacktrace
0 commit comments