Skip to content

Commit 3beb891

Browse files
Henry Smithpieh
Henry Smith
authored andcommitted
fix(gatsby-source-wordpress): check response exists before accessing property (#11349)
1 parent 3742890 commit 3beb891

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const httpExceptionHandler = require(`../http-exception-handler`)
2+
3+
describe(`http-exception-handler`, () => {
4+
it(`handles errors that lack responses without crashing`, () => {
5+
expect(() => httpExceptionHandler({})).not.toThrowError()
6+
})
7+
})

packages/gatsby-source-wordpress/src/http-exception-handler.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ const colorized = require(`./output-color`)
77
*/
88
function httpExceptionHandler(e) {
99
const { response, code } = e
10-
console.log(
11-
colorized.out(
12-
`\nPath: ${response.request.path}`,
13-
colorized.color.Font.FgRed
14-
)
15-
)
1610
if (!response) {
1711
console.log(
1812
colorized.out(
@@ -22,6 +16,12 @@ function httpExceptionHandler(e) {
2216
)
2317
return
2418
}
19+
console.log(
20+
colorized.out(
21+
`\nPath: ${response.request.path}`,
22+
colorized.color.Font.FgRed
23+
)
24+
)
2525
const {
2626
status,
2727
statusText,

0 commit comments

Comments
 (0)