-
-
Notifications
You must be signed in to change notification settings - Fork 74
feat: add interceptError + refactor old Dart code
#159
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
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. |
|
@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
|
@CodingAleCR I've resolved all the merge conflicts. Please, check if something doens't make sense or needs more testing. |
…thods, HTTP methods, interception, retries, and timeout handling
…` representation
|
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. |
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)