Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby): Improve functions compilation error #35196

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/gatsby-cli/src/structured-errors/error-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,14 @@ const errors = {
level: Level.ERROR,
category: ErrorCategory.USER,
},
"11332": {
text: (): string =>
`Failed to compile Gatsby Functions. See the error below for more details.\nNote: The src/api folder is a reserved folder for Gatsby Functions and can't be used for any other files.`,
type: Type.COMPILATION,
level: Level.ERROR,
category: ErrorCategory.USER,
docsUrl: `https://www.gatsbyjs.com/docs/reference/functions/`,
},
// node object didn't pass validation
"11467": {
text: (context): string =>
Expand Down
8 changes: 6 additions & 2 deletions packages/gatsby/src/internal-plugins/functions/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,12 @@ export async function onPreBootstrap({
})
}
})
} catch (e) {
activity.panic(`Failed to compile Gatsby Functions.`, e)
} catch (error) {
activity.panic({
id: `11332`,
error,
context: {},
})
}

activity.end()
Expand Down