Skip to content

Commit

Permalink
Setting code property on HTTPError object to be 'HTTPError' instead o…
Browse files Browse the repository at this point in the history
…f undefined
  • Loading branch information
Drewfergusson committed Jun 2, 2021
1 parent fbf9e69 commit ff56bc5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/core/errors.ts
Expand Up @@ -92,6 +92,7 @@ export class HTTPError extends RequestError {
constructor(response: PlainResponse) {
super(`Response code ${response.statusCode} (${response.statusMessage!})`, {}, response.request);
this.name = 'HTTPError';
this.code = 'HTTPError';
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/error.ts
Expand Up @@ -26,7 +26,7 @@ test('properties', withServer, async (t, server, got) => {
t.truthy(error.options);
t.true({}.propertyIsEnumerable.call(error, 'options'));
t.false({}.propertyIsEnumerable.call(error, 'response'));
t.is(error.code, undefined);
t.is(error.code, 'HTTPError');
t.is(error.message, 'Response code 404 (Not Found)');
t.deepEqual(error.options.url, url);
t.is(error.response.headers.connection, 'close');
Expand Down

0 comments on commit ff56bc5

Please sign in to comment.