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

Omit un-necessary stack trace from invalid routes #24240

Merged
merged 2 commits into from
Apr 20, 2021
Merged
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
11 changes: 7 additions & 4 deletions packages/next/lib/load-custom-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ function checkCustomRoutes(
type: RouteType
): void {
if (!Array.isArray(routes)) {
throw new Error(
`${type}s must return an array, received ${typeof routes}.\n` +
console.error(
`Error: ${type}s must return an array, received ${typeof routes}.\n` +
`See here for more info: https://nextjs.org/docs/messages/routes-must-be-array`
)
process.exit(1)
}

let numInvalidRoutes = 0
Expand Down Expand Up @@ -456,8 +457,10 @@ function checkCustomRoutes(
)
}
console.error()

throw new Error(`Invalid ${type}${numInvalidRoutes === 1 ? '' : 's'} found`)
console.error(
`Error: Invalid ${type}${numInvalidRoutes === 1 ? '' : 's'} found`
)
process.exit(1)
}
}

Expand Down