-
Notifications
You must be signed in to change notification settings - Fork 473
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
refactor: modified error message #9423
base: develop
Are you sure you want to change the base?
refactor: modified error message #9423
Conversation
WalkthroughThis pull request introduces an optional Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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
🧹 Outside diff range and nitpick comments (4)
src/Utils/request/request.ts (2)
21-24
: Consider using a reusable type for errorObj.The errorObj interface is duplicated across files. Consider extracting it to a shared types file for better maintainability.
+// In src/Utils/request/types.ts +export interface ErrorObject { + code: string; + detail: string; +} - errorObj?: { - code: string; - detail: string; - }, + errorObj?: ErrorObject,
50-54
: Simplify the error assignment logic.The nested ternary operation can be simplified for better readability.
- error: res.ok - ? undefined - : errorObj - ? errorObj - : (data as Record<string, unknown>), + error: res.ok ? undefined : (errorObj ?? data as Record<string, unknown>),src/Utils/request/useQuery.ts (1)
20-23
: Use consistent error object type.Once the ErrorObject type is extracted, update this interface to use it as well.
- errorObj?: { - code: string; - detail: string; - }, + errorObj?: ErrorObject,src/components/Facility/DischargeModal.tsx (1)
95-105
: Consider handling loading and error states explicitly.While the code provides an error message for missing consultations, it could benefit from more explicit error handling.
const { data, error } = useTanStackQueryInstead( routes.getConsultation, { pathParams: { id: consultationData.id ?? "" }, prefetch: !!consultationData.id, }, { code: "", detail: t("consultation_missing_warning"), }, ); + if (error) { + return ( + <div className="text-error-600"> + {error.detail || t("general_error")} + </div> + ); + } - const initialDiagnoses = data?.diagnoses; + const initialDiagnoses = data?.diagnoses;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/Utils/request/request.ts
(2 hunks)src/Utils/request/useQuery.ts
(2 hunks)src/components/Facility/DischargeModal.tsx
(1 hunks)
🔇 Additional comments (1)
src/Utils/request/useQuery.ts (1)
42-42
: LGTM: Proper error object propagation.
The errorObj is correctly passed to the request function.
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
DischargeModal
component's error reporting for missing consultation data.Bug Fixes
Documentation