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 {
14
14
response : Response ,
15
15
message : string = `error calling Atlas API`
16
16
) : 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 } > {
17
29
let text : string = "" ;
18
30
let body : ApiError | undefined = undefined ;
19
31
try {
You can’t perform that action at this time.
0 commit comments