phanxipang / fansipan

A simple package that allows you to write your API integrations or SDKs in a elegant way.
https://phanxipang.github.io/fansipan
MIT License
83 stars 2 forks source link

Handle undecodable responses gracefully #25

Closed jenky closed 10 months ago

jenky commented 10 months ago

Introduced a try-catch block in the data() method to catch NotDecodableException when attempting to decode response data. In such cases, decoding will now default to an empty array instead of throwing an unhandled exception. Moreover, clarified method return types in doc comments for onError, throw, and throwIf to reflect the generic Response<T> type.

codecov[bot] commented 10 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (fe40221) 85.39% compared to head (ad92820) 85.29%.

Files Patch % Lines
src/Response.php 50.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #25 +/- ## ============================================ - Coverage 85.39% 85.29% -0.10% - Complexity 326 327 +1 ============================================ Files 39 39 Lines 753 755 +2 ============================================ + Hits 643 644 +1 - Misses 110 111 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.