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

Error name is always overridden with "Error" #66318

Open
skolodyazhnyy opened this issue May 29, 2024 · 1 comment
Open

Error name is always overridden with "Error" #66318

skolodyazhnyy opened this issue May 29, 2024 · 1 comment
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@skolodyazhnyy
Copy link

skolodyazhnyy commented May 29, 2024

Link to the code that reproduces this issue

https://github.com/skolodyazhnyy/nextjs-error-name-overridden

To Reproduce

  1. Start application dev server: npm run dev
  2. Open /demo page

Current vs. Expected behavior

Current behavior:

Expected behavior:

  • Page throws an error with err.name = "PermissionDeniedError"
  • Error component receives error name unchanged: err.name = "PermissionDeniedError"

Which area(s) are affected? (Select all that apply)

Runtime

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

Additional context

I want to render different illustration and localised error message in my error.tsx depending on the error type. The issue is that there is no way to differentiate errors except by analyzing the error message itself, which is often dynamic and prone to changes overtime.

Currently I have to do something like err.message.includes("permission denied") || err.message.includes("access denied") || err.message.includes("forbidden") which is messy to say the least.

@skolodyazhnyy skolodyazhnyy added the bug Issue was opened via the bug report template. label May 29, 2024
@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label May 29, 2024
@skolodyazhnyy
Copy link
Author

skolodyazhnyy commented May 29, 2024

Everything is much worse, in prod all errors are opaque there is not even message to check. Now it makes much more sense that all i see is a generic error screen in production, even if the error is as trivial as "Unauthenticated" 🤦

I stumbled at #49506, bottom line there is no solution except to add error handling code on every page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant