-
Notifications
You must be signed in to change notification settings - Fork 0
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 message update #63
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Can this come from the backend? the response should be a 404 from the fetchScore
- please don;t use regex for error handling, use custom error classes
src/utils/score_res.ts
Outdated
if (!(ecosystem in ({} as EcosystemDestination))) { | ||
throw new Error(`Invalid ecosystem: "${ecosystem}".`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please instead check the return value of the fetch when it is not a 200 for the error field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this approach and while it works fine in dev it does not work in prod. React has a security feature that omits showing the actual error message, instead of the error message you will get
An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included in this error instance which may provide additional details about the nature of the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please look at the nextjs docs for handling server errors with error.js - https://nextjs.org/docs/app/api-reference/file-conventions/error#learn-more-about-error-handling
it looks like the functionality is limited to prevent leaking server data in production.
I would instead return { status: "ecosystem_not_found" } not throw an error
then in the page server component you can do
if (status === "not_found") {
notFound();
}
if (status === "ecosystem_not_found") {
return ... custom component to tell the user
}
also, for your own education - please look into |
No description provided.