-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add better error for null case as well
- Loading branch information
Showing
3 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
# Threw undefined in render | ||
# Threw `undefined`/`null` | ||
|
||
#### Why This Error Occurred | ||
|
||
Somewhere in your code you `throw` an `undefined` 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. | ||
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 | ||
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` | ||
Look in your pages and find where an error could be throwing `undefined` or `null` values and ensure `new Error()` is used instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters