Skip to content

Commit

Permalink
fix(gatsby-source-wordpress): check response exists before accessing …
Browse files Browse the repository at this point in the history
…property (#11349)
  • Loading branch information
Henry Smith authored and pieh committed Jan 28, 2019
1 parent 3742890 commit 3beb891
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const httpExceptionHandler = require(`../http-exception-handler`)

describe(`http-exception-handler`, () => {
it(`handles errors that lack responses without crashing`, () => {
expect(() => httpExceptionHandler({})).not.toThrowError()
})
})
12 changes: 6 additions & 6 deletions packages/gatsby-source-wordpress/src/http-exception-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ const colorized = require(`./output-color`)
*/
function httpExceptionHandler(e) {
const { response, code } = e
console.log(
colorized.out(
`\nPath: ${response.request.path}`,
colorized.color.Font.FgRed
)
)
if (!response) {
console.log(
colorized.out(
Expand All @@ -22,6 +16,12 @@ function httpExceptionHandler(e) {
)
return
}
console.log(
colorized.out(
`\nPath: ${response.request.path}`,
colorized.color.Font.FgRed
)
)
const {
status,
statusText,
Expand Down

0 comments on commit 3beb891

Please sign in to comment.