Skip to content

♻️ Refactor error handling to use showError#294

Merged
IamPekka058 merged 3 commits into
mainfrom
chore/refactor-legacy-error-context
Jul 10, 2026
Merged

♻️ Refactor error handling to use showError#294
IamPekka058 merged 3 commits into
mainfrom
chore/refactor-legacy-error-context

Conversation

@IamPekka058

Copy link
Copy Markdown
Member

This pull request refactors error handling across the app by removing the custom ErrorContext and switching to a standardized error display mechanism provided by useShareScreenshot. This change ensures that error messages are consistently shown throughout the application and simplifies the codebase by eliminating redundant context and hooks.

Error handling refactor:

  • Removed the ErrorContext and its useError hook, along with all related code in ecoscan_app/context/ErrorContext.tsx. ([ecoscan_app/context/ErrorContext.tsxL1-L22](https://github.com/RubberDuckCrew/EcoScan/pull/294/files#diff-9d58594457be7e9ee39982988230191f63d302f5b260e0b1a84fa51530014699L1-L22))
  • Replaced all instances of setError (from useError) with showError (from useShareScreenshot) in both the scan and product screen components, ensuring consistent error messaging. ([[1]](https://github.com/RubberDuckCrew/EcoScan/pull/294/files#diff-b3ff9cc205125bc3b78ded0e83377b57409d8f2f908628c354ad833e79cd078eL17-R20), [[2]](https://github.com/RubberDuckCrew/EcoScan/pull/294/files#diff-b3ff9cc205125bc3b78ded0e83377b57409d8f2f908628c354ad833e79cd078eL32-R31), [[3]](https://github.com/RubberDuckCrew/EcoScan/pull/294/files#diff-b3ff9cc205125bc3b78ded0e83377b57409d8f2f908628c354ad833e79cd078eL43-R47), [[4]](https://github.com/RubberDuckCrew/EcoScan/pull/294/files#diff-f7b3168b880fda207db27220888ebddbd58ee7d3635a661eb12bf7994ba31748L7), [[5]](https://github.com/RubberDuckCrew/EcoScan/pull/294/files#diff-f7b3168b880fda207db27220888ebddbd58ee7d3635a661eb12bf7994ba31748L21-R33))
  • Removed unnecessary imports of useError in related files and updated error handling logic accordingly. ([[1]](https://github.com/RubberDuckCrew/EcoScan/pull/294/files#diff-7b4ab5e8caa731d0427966e9bc664f151d993c6ebaf5975fef7e7ca790fa9afbL3), [[2]](https://github.com/RubberDuckCrew/EcoScan/pull/294/files#diff-f7b3168b880fda207db27220888ebddbd58ee7d3635a661eb12bf7994ba31748L7), [[3]](https://github.com/RubberDuckCrew/EcoScan/pull/294/files#diff-b3ff9cc205125bc3b78ded0e83377b57409d8f2f908628c354ad833e79cd078eL17-R20))

These changes streamline error handling and reduce code duplication, making future maintenance easier.

@github-actions github-actions Bot added the 🛠️ Maintenance General maintenance and updates label Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@IamPekka058, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 11b0ec8f-0fc7-46ca-aaf5-4bf8feb929e8

📥 Commits

Reviewing files that changed from the base of the PR and between 7fa10e3 and 494c14a.

📒 Files selected for processing (4)
  • ecoscan_app/app/(tabs)/(scan)/index.tsx
  • ecoscan_app/components/product/ProductScreen.tsx
  • ecoscan_app/context/ErrorContext.tsx
  • ecoscan_app/hooks/useShareScreenshot.ts

Walkthrough

Error handling in the Scan and Product screens now uses useShareScreenshot().showError. The obsolete useError hook and remaining unused import reference were removed, while ProductScreen navigation fallback behavior remains unchanged.

Changes

Error reporting migration

Layer / File(s) Summary
Scan error reporting
ecoscan_app/app/(tabs)/(scan)/index.tsx
The Scan screen reports empty barcode and product analysis errors through showError.
Product error handling cleanup
ecoscan_app/components/product/ProductScreen.tsx, ecoscan_app/hooks/useAnalyzeProduct.ts, ecoscan_app/context/ErrorContext.tsx
Product loading errors use showError, navigation fallback behavior is preserved, and the obsolete useError implementation and import references are removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: ♻️ Refactor

Suggested reviewers: Friedinger

Poem

I’m a rabbit who scans through the night,
Errors now hop to the snackbar light.
Old hooks disappear,
New messages draw near,
And product paths still turn right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: switching error handling to showError.
Description check ✅ Passed The description directly matches the refactor, removal of ErrorContext, and replacement with showError.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/refactor-legacy-error-context

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@IamPekka058 IamPekka058 force-pushed the chore/refactor-legacy-error-context branch from 7fa10e3 to e2cfac2 Compare July 10, 2026 18:30
@IamPekka058 IamPekka058 force-pushed the chore/refactor-legacy-error-context branch from e2cfac2 to fecddab Compare July 10, 2026 18:31
@IamPekka058 IamPekka058 merged commit 916787e into main Jul 10, 2026
10 checks passed
@IamPekka058 IamPekka058 deleted the chore/refactor-legacy-error-context branch July 10, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ Maintenance General maintenance and updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants