From 867022ab1640abdbe8b1265f10a8bae7221754c1 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 26 Oct 2017 12:32:01 -0700 Subject: [PATCH] Make gatsby-source-react-error-codes plugin fail harder --- .../gatsby-node.js | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/plugins/gatsby-source-react-error-codes/gatsby-node.js b/plugins/gatsby-source-react-error-codes/gatsby-node.js index 24d14696..eef00fbe 100644 --- a/plugins/gatsby-source-react-error-codes/gatsby-node.js +++ b/plugins/gatsby-source-react-error-codes/gatsby-node.js @@ -6,15 +6,23 @@ const errorCodesUrl = exports.sourceNodes = async ({boundActionCreators}) => { const {createNode} = boundActionCreators; - const jsonString = await request(errorCodesUrl); + try { + const jsonString = await request(errorCodesUrl); - createNode({ - id: 'error-codes', - children: [], - parent: 'ERRORS', - internal: { - type: 'ErrorCodesJson', - contentDigest: jsonString, - }, - }); + createNode({ + id: 'error-codes', + children: [], + parent: 'ERRORS', + internal: { + type: 'ErrorCodesJson', + contentDigest: jsonString, + }, + }); + } catch (error) { + console.error( + `The gatsby-source-react-error-codes plugin has failed:\n${error.message}`, + ); + + process.exit(1); + } };