Skip to content

Commit 59cf96f

Browse files
authoredJun 12, 2021
feat: set error.response (#64)
1 parent e9d820f commit 59cf96f

File tree

8 files changed

+587
-579
lines changed

8 files changed

+587
-579
lines changed
 

‎HOW_IT_WORKS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ octokit.hook.after("request", async (response, options) => {
127127
});
128128
octokit.hook.error("request", async (error, options) => {
129129
if (error.status === 304) {
130-
return findInCache(error.headers.etag);
130+
return findInCache(error.response.headers.etag);
131131
}
132132

133133
throw error;

‎docs/src/pages/api/06_hooks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ octokit.hook.after("request", async (response, options) => {
1313
});
1414
octokit.hook.error("request", async (error, options) => {
1515
if (error.status === 304) {
16-
return findInCache(error.headers.etag);
16+
return findInCache(error.response.headers.etag);
1717
}
1818

1919
throw error;

‎package-lock.json

+578-570
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
],
3333
"repository": "github:octokit/rest.js",
3434
"dependencies": {
35-
"@octokit/core": "^3.2.3",
35+
"@octokit/core": "^3.5.0",
3636
"@octokit/plugin-paginate-rest": "^2.6.2",
3737
"@octokit/plugin-request-log": "^1.0.2",
3838
"@octokit/plugin-rest-endpoint-methods": "5.3.1"

‎test/integration/deprecations-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ describe("deprecations", () => {
422422
"2FA required, but options.on2fa is not a function. See https://github.com/octokit/rest.js#authentication"
423423
);
424424
expect(error.status).to.equal(401);
425-
expect(!!error.headers).to.equal(true);
425+
expect(!!error.response.headers).to.equal(true);
426426
expect(!!error.request).to.equal(true);
427427
});
428428
});
@@ -977,7 +977,7 @@ describe("deprecations", () => {
977977
"2FA required, but options.on2fa is not a function. See https://github.com/octokit/rest.js#authentication"
978978
);
979979
expect(error.status).to.equal(401);
980-
expect(!!error.headers).to.equal(true);
980+
expect(!!error.response.headers).to.equal(true);
981981
expect(!!error.request).to.equal(true);
982982
});
983983
});

‎test/integration/request-errors-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe("request errors", () => {
103103
.catch((error) => {
104104
expect(error.name).to.equal("HttpError");
105105
expect(error.status).to.equal(401);
106-
expect(error.headers).to.deep.equal({
106+
expect(error.response.headers).to.deep.equal({
107107
"content-type": "application/json",
108108
"x-foo": "bar",
109109
});

‎test/scenarios/errors.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ describe("api.github.com", () => {
2424
expect(error.message).toEqual(
2525
`Validation Failed: {"resource":"Label","code":"invalid","field":"color"}`
2626
);
27-
expect(error.errors).toStrictEqual([
27+
expect(error.response.data.errors).toStrictEqual([
2828
{
2929
resource: "Label",
3030
code: "invalid",
3131
field: "color",
3232
},
3333
]);
34-
expect(error.documentation_url).toMatch(
34+
expect(error.response.data.documentation_url).toMatch(
3535
new RegExp("rest/reference/issues#create-a-label")
3636
);
3737
});

‎test/typescript-validate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default async function () {
100100
// @ts-expect-error TODO: .error hook should accept a return of a valid response
101101
octokit.hook.error("request", async (error, options) => {
102102
if ("status" in error && error.status === 304) {
103-
return findInCache(error.headers.etag);
103+
return findInCache(error.response.headers.etag);
104104
}
105105

106106
throw error;

0 commit comments

Comments
 (0)
Please sign in to comment.