File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ export class ApiClientError extends Error {
1414 response : Response ,
1515 message : string = `error calling Atlas API`
1616 ) : Promise < ApiClientError > {
17+ const { text, body } = await this . extractErrorMessage ( response ) ;
18+
19+ const errorMessage = text . length > 0
20+ ? `${ message } : [${ response . status } ${ response . statusText } ] ${ text . trim ( ) } `
21+ : `${ message } : ${ response . status } ${ response . statusText } ` ;
22+
23+ return new ApiClientError ( errorMessage , response , body ) ;
24+
25+ return new ApiClientError ( text , response , body ) ;
26+ }
27+
28+ private static async extractErrorMessage ( response : Response ) : Promise < { text : string ; body : ApiError | undefined } > {
1729 let text : string = "" ;
1830 let body : ApiError | undefined = undefined ;
1931 try {
You can’t perform that action at this time.
0 commit comments