rsnext/errors/threw-undefined.mdx
Delba de Oliveira 44d1a1cb15
docs: Migrate error messages to MDX and App Router. (#52038)
This PR is part of a larger effort to migrate error messages to MDX and
use App Router: https://github.com/vercel/front/pull/23459
2023-07-05 06:11:16 -07:00

23 lines
577 B
Text

---
title: 'Threw `undefined` / `null`'
---
## Why This Error Occurred
Somewhere in your code you `throw` an `undefined` or `null` value. Since this isn't a valid error there isn't a stack trace. We show this error instead to let you know what to look for.
```js filename="pages/index.js"
function getData() {
let error
throw error
}
function Page() {
const error = data?.error || null
throw error
}
```
## Possible Ways to Fix It
Look in your pages and find where an error could be throwing `undefined` or `null` values and ensure `new Error()` is used instead.