-
Notifications
You must be signed in to change notification settings - Fork 543
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
API Erorr Handler: early exit if error can be silenced #10409
API Erorr Handler: early exit if error can be silenced #10409
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Request Creator
participant EH as handleHttpError
Caller->>EH: Call handleHttpError(error)
alt error.silent is true<br>or error.name == "AbortError"
EH-->>Caller: Return early (skip processing)
else Error not skipped
EH-->>Caller: Process error (handle & display notification)
end
Possibly related PRs
Poem
✨ Finishing Touches
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. |
Deploying care-fe with
|
Latest commit: |
0b3a84d
|
Status: | ✅ Deploy successful! |
Preview URL: | https://92e8a016.care-fe.pages.dev |
Branch Preview URL: | https://rithviknishad-fix-api-error.care-fe.pages.dev |
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/Utils/request/errorHandler.ts (1)
9-12
: LGTM! Consider adding a type definition for silent errors.The implementation correctly handles both silent errors and AbortError. The use of
"silent" in error
is a type-safe way to check for the optional property.Consider adding a type definition for errors with the silent property:
interface SilentableError extends Error { silent?: boolean; }Then update the function signature:
export function handleHttpError(error: Error | SilentableError)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Utils/request/errorHandler.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: cypress-run (1)
- GitHub Check: Cloudflare Pages: care-fe
🔇 Additional comments (1)
src/Utils/request/errorHandler.ts (1)
10-10
: Verify AbortError handling across the codebase.Let's ensure that AbortError is consistently handled across the codebase and that we're not missing any cases where we should be handling cancelled requests.
✅ Verification successful
🏁 Script executed:
#!/bin/bash # Search for AbortError handling patterns echo "Searching for AbortError handling patterns..." rg -A 3 "AbortError|aborted|cancelled|canceled" --type ts # Search for fetch/axios request cancellation echo "Searching for request cancellation patterns..." rg -A 3 "AbortController|CancelToken|cancel\(" --type tsLength of output: 11316
AbortError Handling Verified Across Codebase
- The pattern for checking
error.name === "AbortError"
is consistently applied in bothsrc/Utils/request/errorHandler.ts
andsrc/Utils/request/request.ts
.- The use of
AbortController
in various components confirms that request cancellations are properly set up.
CARE
|
Project |
CARE
|
Branch Review |
rithviknishad/fix/api-error-handler-move-silent-check-to-top
|
Run status |
|
Run duration | 05m 59s |
Commit |
|
Committer | Rithvik Nishad |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
0
|
|
0
|
|
0
|
|
10
|
View all changes introduced in this branch ↗︎ |
@rithviknishad Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
Proposed Changes
cc: @khavinshankar
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit