Skip to content

Commit

Permalink
fix(connext): display error message for 400 status code (#1911)
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl Ranna authored Sep 22, 2020
1 parent 0a2bdfd commit b4e1858
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/connextclient/ConnextClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,12 +819,18 @@ class ConnextClient extends SwapClient {
this.logger.trace(`sending request to ${endpoint}${payloadStr ? `: ${payloadStr}` : ''}`);
const req = http.request(options, async (res) => {
let err: XudError | undefined;
let body;
switch (res.statusCode) {
case 200:
case 201:
case 204:
resolve(res);
break;
case 400:
body = await parseResponseBody<ConnextErrorResponse>(res);
this.logger.error(`400 status error: ${JSON.stringify(body)}`);
reject(body);
break;
case 402:
err = errors.INSUFFICIENT_BALANCE;
break;
Expand All @@ -835,9 +841,9 @@ class ConnextClient extends SwapClient {
err = errors.TIMEOUT;
break;
case 409:
const body = await parseResponseBody<ConnextErrorResponse>(res);
this.logger.error(`409 status error: ${body}`);
reject(body.message);
body = await parseResponseBody<ConnextErrorResponse>(res);
this.logger.error(`409 status error: ${JSON.stringify(body)}`);
reject(body);
break;
case 500:
err = errors.SERVER_ERROR(res.statusCode, res.statusMessage);
Expand Down

0 comments on commit b4e1858

Please sign in to comment.