-
Notifications
You must be signed in to change notification settings - Fork 9
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
Handle invalid pagination parameters via exceptions #121
Handle invalid pagination parameters via exceptions #121
Conversation
4fda9d7
to
8c5aafe
Compare
00e11c0
to
1871cab
Compare
// This would be nicer, but this would also trigger react-error-overlay (besides our error boundary). | ||
// We don't want that, so now, we are stuck with throwing a string, instead of a proper error. | ||
// throw new AppError(AppErrors.InvalidPageNumber) |
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.
😢
<TransactionsCard blockHeight={blockHeight} /> | ||
<ErrorBoundary> | ||
<TransactionsCard blockHeight={blockHeight} /> | ||
</ErrorBoundary> |
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.
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 find the first one more awkward. Technically speaking the error only impacts the transaction list, so why shouldn't we seen the data about the block itself?
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 see first one as giving clear instructions that URL is malformed. And second one like it could be an app bug
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 can see your point. I wonder which viewpoint is more prevalent. I'm inclined to defer this question to @donouwens .
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.
My suggestion would be to have a dedicated error state for those situations.
Like this: https://www.figma.com/file/ifCrok8cP5ymEYjMa2PIi9/MVP?node-id=2934%3A157297&t=CoRB18ePaVLjZtDq-1
@lukaw3d All other data is valid and relevant so why would we hide it? Is there a threat to it in any kind way?
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.
src/routes.tsx
Outdated
@@ -63,6 +66,7 @@ export const routes: RouteObject[] = [ | |||
{ | |||
path: `/${paraTime}/transactions`, | |||
element: <TransactionsPage />, | |||
errorElement: <RoutingErrorPage />, |
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.
The drawback is that there is no TypeScript-level test to verify that the errorElement (or some other error boundary) is always there
Is there a way to add a top-level error handler?
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.
Yes, in fact it's recommended by React Router. What should be the text? Just a generic unknown error?
Wherever it's needed. (On some other routes we already had `errorElements` declared.)
1871cab
to
440020b
Compare
We have one at the root now, that should catch all.
This depends on #124. (That's the first commit.) Please merge that one first, then rebase.This is an alternate implementation of #119. (We only need one of them.)
This time we throw an error from the pagination hook, and apply React Router's
errorElement
feature to catch it.Analysis: