@@ -648,18 +648,20 @@ function hasStringProperty(obj: any, property: string): boolean {
648648function parseServiceErrorMessage ( response : any ) : string | undefined {
649649 let message ;
650650
651- if (
652- Array . isArray ( response . errors ) &&
653- response . errors . length > 0 &&
654- hasStringProperty ( response . errors [ 0 ] , 'message' )
655- ) {
656- message = response . errors [ 0 ] . message ;
657- } else if ( hasStringProperty ( response , 'error' ) ) {
658- message = response . error ;
659- } else if ( hasStringProperty ( response , 'message' ) ) {
660- message = response . message ;
661- } else if ( hasStringProperty ( response , 'errorMessage' ) ) {
662- message = response . errorMessage ;
651+ if ( response ) {
652+ if (
653+ Array . isArray ( response . errors ) &&
654+ response . errors . length > 0 &&
655+ hasStringProperty ( response . errors [ 0 ] , 'message' )
656+ ) {
657+ message = response . errors [ 0 ] . message ;
658+ } else if ( hasStringProperty ( response , 'error' ) ) {
659+ message = response . error ;
660+ } else if ( hasStringProperty ( response , 'message' ) ) {
661+ message = response . message ;
662+ } else if ( hasStringProperty ( response , 'errorMessage' ) ) {
663+ message = response . errorMessage ;
664+ }
663665 }
664666
665667 logger . info ( `Parsing service error message: ${ message } ` ) ;
0 commit comments