Skip to content

Commit 690fe91

Browse files
committed
Handle exception returning HttpClientException instance
1 parent f654498 commit 690fe91

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/httpClient/httpURLConnectionClient.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,16 @@ class HttpURLConnectionClient implements ClientInterface {
184184
exception = getException(response.body);
185185
}
186186
} catch (e) {
187-
reject(exception);
188-
} finally {
189-
reject(exception);
187+
// parsing error
188+
exception = new HttpClientException({
189+
message: `HTTP Exception: ${response.statusCode}. Error parsing response: ${(e as Error).message}`,
190+
statusCode: response.statusCode,
191+
responseHeaders: response.headers,
192+
responseBody: response.body,
193+
});
190194
}
195+
196+
return reject(exception);
191197
}
192198

193199
resolve(response.body as string);

0 commit comments

Comments
 (0)