-
Notifications
You must be signed in to change notification settings - Fork 25
feat: render oops errors #2752
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
feat: render oops errors #2752
Conversation
resolves: #2723
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR enhances error handling across the views domain by strengthening the API service's Changes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/pages/views/components/SingleView.tsx (1)
72-79: Consider simplifying error property extraction.The manual extraction of error properties (
message,error,detail,msg) here may be redundant. Based on the relevant code snippet,toastErroralready handles extractingresponse?.data?.errorandresponse?.data?.messagefrom error objects. You might be able to simplify this by passingresult.errordirectly totoastError, unless you've confirmed that these specific properties aren't handled by the existing error handling chain.Apply this diff if the toastError function handles these cases:
if (result.isError) { - const err = result.error as any; toastError( - err?.message || - err?.error || - err?.detail || - err?.msg || - "Failed to refresh view" + result.error || "Failed to refresh view" ); return; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/api/services/views.ts(1 hunks)src/pages/audit-report/components/View/View.tsx(2 hunks)src/pages/views/ViewPage.tsx(4 hunks)src/pages/views/components/SingleView.tsx(4 hunks)src/pages/views/components/ViewSection.tsx(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/pages/views/components/SingleView.tsx (2)
src/components/Toast/toast.ts (1)
toastError(15-25)src/components/ErrorViewer.tsx (1)
ErrorViewer(68-115)
src/pages/audit-report/components/View/View.tsx (1)
src/components/ErrorViewer.tsx (1)
ErrorViewer(68-115)
src/pages/views/components/ViewSection.tsx (1)
src/components/ErrorViewer.tsx (1)
ErrorViewer(68-115)
src/pages/views/ViewPage.tsx (1)
src/components/ErrorViewer.tsx (1)
ErrorViewer(68-115)
🔇 Additional comments (6)
src/api/services/views.ts (2)
93-100: LGTM! Defensive error handling.The defensive JSON parsing with fallback to a structured error object ensures consistent error propagation even when the response body is malformed or non-JSON.
103-109: Error detection approach is correct per API design.This properly detects both HTTPError and OopsError responses (both defined with
erroras their primary field insrc/api/types/error.ts). The pattern of checking for theerrorproperty is the standard way the backend indicates errors in 200 OK responses. By throwing the entire data object, you preserve all available context including code, public message, hint, stacktrace, trace, and other diagnostic fields for error handling.src/pages/audit-report/components/View/View.tsx (1)
259-263: LGTM! Consistent error rendering.The replacement of inline error text with ErrorViewer provides a consistent, user-friendly error display that can show details (including stacktraces for "oops" errors) in a collapsible section.
src/pages/views/components/SingleView.tsx (1)
135-135: LGTM! Consistent error rendering with ErrorViewer.Both error and not-found states now use ErrorViewer for consistent, user-friendly error display.
Also applies to: 148-151
src/pages/views/components/ViewSection.tsx (1)
77-82: LGTM! Consistent error rendering within sections.The ErrorViewer integration provides a consistent error display for section loading failures, maintaining the collapsible section structure while improving error presentation.
src/pages/views/ViewPage.tsx (1)
26-26: LGTM! Improved type safety and consistent error rendering.The changes improve error handling in multiple ways:
- The error state type change to
unknown(line 26) aligns with ErrorViewer's flexible error handling.- Simplified error catching (line 61) reduces complexity.
- Consistent ErrorViewer usage for both error states provides a unified error presentation.
Also applies to: 61-61, 80-93
❌ Deploy Preview for flanksource-demo-stable failed. Why did it fail? →
|
❌ Deploy Preview for clerk-saas-ui failed. Why did it fail? →
|
resolves: #2723
Summary by CodeRabbit
Bug Fixes
Style
✏️ Tip: You can customize this high-level summary in your review settings.