File tree Expand file tree Collapse file tree 2 files changed +26
-9
lines changed
gatsby-source-graphcms/src Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import { PLUGIN_NAME } from './util/constants'
2323import { getImageBase64 , getBase64DataURI } from './util/getImageBase64'
2424import { getImageDominantColor } from './util/getDominantColor'
2525import { getTracedSVG } from './util/getTracedSVG'
26+ import { reportPanic } from './util/reportPanic'
2627
2728export function pluginOptionsSchema ( { Joi } ) {
2829 return Joi . object ( {
@@ -88,28 +89,34 @@ const createSourcingConfig = async (
8889 } )
8990 . then ( ( response ) => {
9091 if ( ! response . ok ) {
91- return reporter . panic (
92- `[${ PLUGIN_NAME } ]: Problem building GraphCMS nodes` ,
93- new Error ( response . statusText )
92+ return reportPanic (
93+ 1 ,
94+ 'Problem building GraphCMS nodes' ,
95+ response . statusText ,
96+ reporter
9497 )
9598 }
9699
97100 return response . json ( )
98101 } )
99102 . then ( ( response ) => {
100103 if ( response . errors ) {
101- return reporter . panic (
102- `[${ PLUGIN_NAME } ]: Problem building GraphCMS nodes` ,
103- new Error ( response . errors )
104+ return reportPanic (
105+ 2 ,
106+ 'Problem building GraphCMS nodes' ,
107+ JSON . stringify ( response . errors , null , 2 ) ,
108+ reporter
104109 )
105110 }
106111
107112 return response
108113 } )
109114 . catch ( ( error ) => {
110- return reporter . panic (
111- `[${ PLUGIN_NAME } ]: Problem building GraphCMS nodes` ,
112- new Error ( error )
115+ return reportPanic (
116+ 3 ,
117+ 'Problem building GraphCMS nodes' ,
118+ JSON . stringify ( error , null , 2 ) ,
119+ reporter
113120 )
114121 } )
115122 }
Original file line number Diff line number Diff line change 1+ import { PLUGIN_NAME } from './constants'
2+
3+ export function reportPanic ( id , message , error , reporter ) {
4+ return reporter . panic ( {
5+ context : {
6+ id,
7+ sourceMessage : `[${ PLUGIN_NAME } ]: ${ message } \n\n ${ new Error ( error ) } ` ,
8+ } ,
9+ } )
10+ }
You can’t perform that action at this time.
0 commit comments