Skip to content

Conversation

@renefloor
Copy link
Collaborator

Submit a pull request

Linear: FLU-322

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

Currently the intercepter always try to parse the error body into a StreamApiError, but that doesn't always make sense.
For example a 404 can give a body of 404 page not found, trying to parse this will throw an error FormatException, which makes the console log very confusing.

Screenshots / Videos

Before:
image

After:
Screenshot 2025-11-11 at 15 55 14

@renefloor renefloor requested a review from a team as a code owner November 11, 2025 15:00
@codecov
Copy link

codecov bot commented Nov 11, 2025

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.39%. Comparing base (457b293) to head (a8b5381).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...stream_core/lib/src/api/stream_core_dio_error.dart 0.00% 5 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #18      +/-   ##
==========================================
+ Coverage   26.56%   28.39%   +1.83%     
==========================================
  Files          49       49              
  Lines         960      972      +12     
==========================================
+ Hits          255      276      +21     
+ Misses        705      696       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xsahil03x xsahil03x changed the title fix error while parsing unknown body fix(llc): fix error while parsing unknown body Nov 11, 2025
Refactors the `toClientException` extension on `DioException` to more safely parse the `StreamApiError`.

The new implementation uses `runSafelySync` and a switch expression to handle different response data types (Map or String) when creating a `StreamApiError` from JSON, replacing the previous `try-catch` block.
@xsahil03x xsahil03x merged commit 6fe442f into main Dec 3, 2025
5 checks passed
@xsahil03x xsahil03x deleted the fix/parsing-unknown-body branch December 3, 2025 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants