File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,7 +38,12 @@ export class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
3838 message : res ,
3939 } ;
4040
41- applicationRef . reply ( host . getArgByIndex ( 1 ) , message , exception . getStatus ( ) ) ;
41+ const response = host . getArgByIndex ( 1 ) ;
42+ if ( ! applicationRef . isHeadersSent ( response ) ) {
43+ applicationRef . reply ( response , message , exception . getStatus ( ) ) ;
44+ } else {
45+ applicationRef . end ( response ) ;
46+ }
4247 }
4348
4449 public handleUnknownError (
@@ -55,7 +60,14 @@ export class BaseExceptionFilter<T = any> implements ExceptionFilter<T> {
5560 statusCode : HttpStatus . INTERNAL_SERVER_ERROR ,
5661 message : MESSAGES . UNKNOWN_EXCEPTION_MESSAGE ,
5762 } ;
58- applicationRef . reply ( host . getArgByIndex ( 1 ) , body , body . statusCode ) ;
63+
64+ const response = host . getArgByIndex ( 1 ) ;
65+ if ( ! applicationRef . isHeadersSent ( response ) ) {
66+ applicationRef . reply ( response , body , body . statusCode ) ;
67+ } else {
68+ applicationRef . end ( response ) ;
69+ }
70+
5971 if ( this . isExceptionObject ( exception ) ) {
6072 return BaseExceptionFilter . logger . error (
6173 exception . message ,
You can’t perform that action at this time.
0 commit comments