Skip to content

Commit

Permalink
Unable to read error message from response header (microsoft#339)
Browse files Browse the repository at this point in the history
* Added response headers to err answer

* Corrected message in test

* Corrected package version
  • Loading branch information
Roman-Shchukin authored and ajuanjojjj committed Jul 5, 2024
1 parent 2209ed9 commit dcfecec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
4 changes: 4 additions & 0 deletions lib/RestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ export class RestClient {
err['result'] = response.result;
}

if (response.headers) {
err['responseHeaders'] = response.headers;
}

reject(err);
} else {
resolve(response);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typed-rest-client",
"version": "1.8.10",
"version": "1.8.11",
"description": "Node Rest and Http Clients for use with TypeScript",
"main": "./RestClient.js",
"scripts": {
Expand Down
26 changes: 13 additions & 13 deletions test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/tests/resttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ describe('Rest Tests', function () {
catch(err) {
assert(err['statusCode'] == 401, "statusCode should be 401");
assert(err.message && err.message.length > 0, "should have error message");
assert(err['responseHeaders'], "err must contain responseHeaders");
}
});

Expand All @@ -331,6 +332,7 @@ describe('Rest Tests', function () {
catch(err) {
assert(err['statusCode'] == 500, "statusCode should be 500");
assert(err.message && err.message.length > 0, "should have error message");
assert(err['responseHeaders'], "err must contain responseHeaders");
}
});

Expand Down

0 comments on commit dcfecec

Please sign in to comment.