Unverified Commit aab6b37e authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Omit un-necessary stack trace from invalid routes (#24240)

This removes the extra stack trace from throwing an error instead of logging and then exiting since the stack trace doesn't provide any additional information that is helpful for debugging in this case. 

<details>

<summary>Before screenshot</summary>

![image](https://user-images.githubusercontent.com/22380829/115301794-4f3b1280-a127-11eb-8a0d-0797efb8fc9f.png)


</details>

<details>

<summary>After screenshot</summary>

<img width="962" alt="Screen Shot 2021-04-19 at 3 53 45 PM" src="https://user-images.githubusercontent.com/22380829/115301901-6ed23b00-a127-11eb-83f9-e3f4cf0ed8fe.png">


</details>
parent e0da6a60
...@@ -174,10 +174,11 @@ function checkCustomRoutes( ...@@ -174,10 +174,11 @@ function checkCustomRoutes(
type: RouteType type: RouteType
): void { ): void {
if (!Array.isArray(routes)) { if (!Array.isArray(routes)) {
throw new Error( console.error(
`${type}s must return an array, received ${typeof routes}.\n` + `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` `See here for more info: https://nextjs.org/docs/messages/routes-must-be-array`
) )
process.exit(1)
} }
let numInvalidRoutes = 0 let numInvalidRoutes = 0
...@@ -456,8 +457,10 @@ function checkCustomRoutes( ...@@ -456,8 +457,10 @@ function checkCustomRoutes(
) )
} }
console.error() console.error()
console.error(
throw new Error(`Invalid ${type}${numInvalidRoutes === 1 ? '' : 's'} found`) `Error: Invalid ${type}${numInvalidRoutes === 1 ? '' : 's'} found`
)
process.exit(1)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment