Skip to content

Commit 6b01efe

Browse files
authored
fix: make 11321 and 11330 error formatters backward compatible (#22249)
1 parent a668f69 commit 6b01efe

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/gatsby-cli/src/structured-errors/error-map.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ const errors = {
312312
text: (context): string =>
313313
`"${context.pluginName}" threw an error while running the ${
314314
context.api
315-
} lifecycle:\n\n${context.sourceMessage}${optionalGraphQLInfo(context)}`,
315+
} lifecycle:\n\n${context.sourceMessage ??
316+
context.message}${optionalGraphQLInfo(context)}`,
316317
type: Type.PLUGIN,
317318
level: Level.ERROR,
318319
},
@@ -408,7 +409,15 @@ const errors = {
408409
// "X" is not defined in Gatsby's node APIs
409410
"11330": {
410411
text: (context): string =>
411-
`"${context.pluginName}" threw an error while running the ${context.api} lifecycle:\n\n${context.sourceMessage}\n\n${context.codeFrame}\n\nMake sure that you don't have a typo somewhere and use valid arguments in ${context.api} lifecycle.\nLearn more about ${context.api} here: https://www.gatsbyjs.org/docs/node-apis/#${context.api}`,
412+
`"${context.pluginName}" threw an error while running the ${
413+
context.api
414+
} lifecycle:\n\n${context.sourceMessage ?? context.message}\n\n${
415+
context.codeFrame
416+
}\n\nMake sure that you don't have a typo somewhere and use valid arguments in ${
417+
context.api
418+
} lifecycle.\nLearn more about ${
419+
context.api
420+
} here: https://www.gatsbyjs.org/docs/node-apis/#${context.api}`,
412421
type: Type.PLUGIN,
413422
level: Level.ERROR,
414423
},

0 commit comments

Comments
 (0)