2023-07-05 15:11:16 +02:00
---
title: 'Threw `undefined` / `null`'
---
2019-03-13 21:08:06 +01:00
2023-07-05 15:11:16 +02:00
## Why This Error Occurred
2019-03-13 21:08:06 +01:00
2022-01-11 21:40:03 +01:00
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.
2023-07-05 15:11:16 +02:00
```js filename="pages/index.js"
2022-01-11 21:40:03 +01:00
function getData() {
let error
throw error
}
function Page() {
const error = data?.error || null
throw error
}
```
2019-03-13 21:08:06 +01:00
2023-07-05 15:11:16 +02:00
## Possible Ways to Fix It
2019-03-13 21:08:06 +01:00
2022-01-11 21:40:03 +01:00
Look in your pages and find where an error could be throwing `undefined` or `null` values and ensure `new Error()` is used instead.