@@ -24,18 +24,27 @@ export class ExceptionFilter implements IExceptionFilter {
2424 if ( exception instanceof HttpException ) {
2525 status = exception . getStatus ( ) ;
2626 message = exception . getResponse ( ) ;
27- } else if ( exception . response ) {
28- status = exception . response . status ;
29- message =
30- exception . response . data ?. message || exception . response . statusText ;
31- } else {
32- let formattedError = exception ;
33- if ( exception instanceof AxiosError ) {
34- formattedError = errorUtils . formatError ( exception ) ;
35- formattedError . outgoingRequestUrl = exception . config ?. url ;
27+ } else if ( exception instanceof AxiosError ) {
28+ /**
29+ * All requests we made to external services are supposed to be made by axios,
30+ * and we either proxy response code or act as a "bad gateway" if sending fails.
31+ */
32+ status = exception . response ?. status || HttpStatus . BAD_GATEWAY ;
33+ if ( status >= 200 && status < 400 ) {
34+ /**
35+ * In case some 3rd party that we are using (e.g. graphql client)
36+ * throws with such status code (their API schema can be literally anything)
37+ */
38+ this . logger . warn ( 'Unexpected http status in exception response' , {
39+ status,
40+ error : errorUtils . formatError ( exception ) ,
41+ path : request . url ,
42+ } ) ;
3643 }
44+ message = exception . response ?. data ?. message || 'Bad gateway' ;
45+ } else {
3746 this . logger . error ( 'Unhandled exception' , {
38- error : formattedError ,
47+ error : errorUtils . formatError ( exception ) ,
3948 path : request . url ,
4049 } ) ;
4150 }
0 commit comments