File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -388,6 +388,14 @@ describe('Error Extractors', () => {
388388 expect ( extractErrorMessage ( errorInfo , ErrorExtractorId . WIZA_ERRORS ) ) . toBe ( 'Bad gateway' )
389389 } )
390390
391+ it ( 'ignores a non-string top-level message' , ( ) => {
392+ const errorInfo : ErrorInfo = { status : 422 , data : { message : [ 'bad filter' ] } }
393+
394+ expect ( extractErrorMessage ( errorInfo , ErrorExtractorId . WIZA_ERRORS ) ) . toBe (
395+ 'Request failed with status 422'
396+ )
397+ } )
398+
391399 it ( 'falls back to the status when Wiza sends an empty message' , ( ) => {
392400 const errorInfo : ErrorInfo = { status : 400 , data : { status : { code : 400 , message : '' } } }
393401
Original file line number Diff line number Diff line change @@ -521,10 +521,11 @@ const ERROR_EXTRACTORS: ErrorExtractorConfig[] = [
521521 examples : [ 'Wiza' ] ,
522522 extract : ( errorInfo ) => {
523523 const data = errorInfo ?. data
524- if ( typeof data === 'string' ) return data . trim ( ) || undefined
525- const message = data ?. status ?. message
526- if ( typeof message === 'string' && message . trim ( ) ) return message . trim ( )
527- return data ?. message
524+ const candidates = [ data , data ?. status ?. message , data ?. message ]
525+ for ( const candidate of candidates ) {
526+ if ( typeof candidate === 'string' && candidate . trim ( ) ) return candidate . trim ( )
527+ }
528+ return undefined
528529 } ,
529530 } ,
530531 {
You can’t perform that action at this time.
0 commit comments