feat: add interceptError + refactor old Dart code - #159
Merged
Conversation
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
techouse
commented
Jul 22, 2025
ContributorAuthor
@CodingAleCR I'll resolve all the merge conflicts in the evening. :) |
# Conflicts: # lib/extensions/uri.dart # lib/http/intercepted_client.dart # lib/models/interceptor_contract.dart
ContributorAuthor
@CodingAleCR I've resolved all the merge conflicts. Please, check if something doens't make sense or needs more testing. |
td2thinh
commented
Jul 22, 2025
Contributor
…thods, HTTP methods, interception, retries, and timeout handling
CodingAleCR
approved these changes
Jul 23, 2025
CodingAleCR
commented
Jul 23, 2025
Owner
I'll probably make a pre-release cut soon so it can be fully tried out before releasing. There's quite a few changes merging too, so I want to avoid disrupting anyone using the library. |
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several enhancements and refactors across the codebase, focusing on improving error handling, adopting modern Dart patterns, and enhancing code readability. Key changes include adding error interception capabilities, replacing conditional blocks with
switchexpressions for improved clarity, and refining method signatures and type annotations for better type safety.Error Handling Enhancements:
interceptErrormethod toLoggerInterceptorfor logging request, response, error, and stack trace details when an error occurs. (example/lib/common.dart, example/lib/common.dartR29-R50)_interceptErrorinInterceptedClientto allow interceptors to handle errors during request execution. (lib/http/intercepted_client.dart, lib/http/intercepted_client.dartR351-R369)_attemptRequestinInterceptedClientto call_interceptErrorwhen an exception is caught, providing additional error context. (lib/http/intercepted_client.dart, lib/http/intercepted_client.dartR309-R314)Refactoring with
switchExpressions:if-elseblocks withswitchexpressions inBaseRequestCopyWithandBaseResponseCopyWithextensions to simplify logic and improve readability. (lib/extensions/base_request.dart, [1][2];lib/extensions/base_response_io.dart, [3][4];lib/extensions/base_response_none.dart, [5][6]Code Readability and Type Safety:
finalkeywords and refined type annotations across multiple files to enforce immutability and enhance clarity (e.g.,MultipartRequest,Request,StreamedRequest). (lib/extensions/multipart_request.dart, [1];lib/extensions/request.dart, [2];lib/extensions/streamed_request.dart, [3]InterceptedClientto uselate finalfor_innerand added type annotations for variables likeresponseandmessage. (lib/http/intercepted_client.dart, [1][2]API Enhancements:
OPTIONSHTTP method in theHttpMethodenum and refactored itsfromStringandasStringmethods to useswitchexpressions for consistency. (lib/http/http_methods.dart, lib/http/http_methods.dartL10-R32)Simplifications and Optimizations:
addParametersmethod in theUriextension by using a concise functional approach with null-aware operators. (lib/extensions/uri.dart, lib/extensions/uri.dartL4-R16)