-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Improve DioError
s
#1405
Improve DioError
s
#1405
Conversation
This reverts commit 0107079. # Conflicts: # dio/CHANGELOG.md
Good idea! Can you include an example of a stacktrace message before and after your PR so people can see the difference? |
I'm still thinking about how to produce those cases, in order to test it. Do you have any ideas? |
Just a reminder too myself: Consider raising to Dart 2.16 and using |
@kuhnroyal Do you mind sharing your test cases? Then I can go through them. |
It's nothing special, I only tested:
|
fix: abort request when timeout occurs
…velop � Conflicts: � dio/CHANGELOG.md
Correct JSON MIME Type detection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ueman. The change looks valid overall, with only a few nit-pickings.
Also, there are a few things I'm considering:
- Are you willing to contribute by letting us pick the PR to another community-maintained
dio
? (We'll announce the new repo later once we merge PRs as much as possible.) - It might be better to add some tests.
.DS_Store
can be removed from the PR.
/// It occurs when url is opened timeout. | ||
connectTimeout, | ||
/// Caused by a connection timeout. | ||
connectionTimeout, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes with DioErrorType
should be considered as a breaking change, which means you'll need to update the migration guide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is a breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I need to add anything to the migration guide. From a user's point of view, nothing changes. The user can still catch exceptions the same way as before. All breaking changes are done from within the package in this PR.
Sure.
I agree, any specific suggestions for tests? Just so I don't miss anything, you might think is important.
Yes, good point |
Thanks!
IMO tests should be covered by checking if requests throw corresponding exceptions in condition. |
# Conflicts: # dio/CHANGELOG.md # dio/lib/src/adapters/io_adapter.dart # dio/lib/src/options.dart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we've already merged a couple PRs in the fork, I would suggest that we can submit this PR to the fork directly.
@@ -630,6 +636,11 @@ abstract class DioMixin implements Dio { | |||
} | |||
} | |||
|
|||
StackTrace? stackTrace; | |||
if (maybeStackTrace is StackTrace?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybeStackTrace
will always be StackTrace
. The condition can be maybeStackTrace != StackTrace.empty
.
|
||
# 4.0.5-beta1 | ||
- Add option to instantiate a `HttpClientAdapter`, which is platform independent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we need to change the base branch to develop
.
StackTrace.current, | ||
); | ||
xhr.abort(); | ||
if (haveSent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be fix by another PR.
|
||
/// When the request is cancelled, dio will throw a error with this type. | ||
cancel, | ||
requestCancelled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users usually ignore canceled requests since they are meant to do it, which means they'll rely on the en. Maybe we can keep the naming at least for the least breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would now suggest submitting the PR to the fork directly. Also, the target branch should be main
.
I don't have the permissions to do that |
Sorry. It should be granted now. |
Hi everyone! We've made our hardfork repo public and published a new version of |
I am missing a lot of stacktraces in |
All the server response errors have no stackTrace at all. It is impossible to tell where the error originated. |
[Improve nullability in DioMixin.assureResponse](8418c72) * there should never be a case where there are not `RequestOptions` available * this is technically a breaking change but we should instead mark this `@internal` in the future [Fix missing source stacktrace in DioError](4f4ffe4) * a `DioError` should always have a meaningful stacktrace which points to the actual invocation of `Dio.get/post/xxx` * `Dio` historically lost a lot of this source information due to a multitude of asynchronous calls * now the source stacktrace is consistently being set into the `RequestOptions` instance and can later be retrieved and used when a `DioError` is constructed * additionally a `DioError` may contain another cause which may itself contain a separate stackTrace with more detailed information ### New Pull Request Checklist - [x] I have read the [Documentation](https://pub.dev/documentation/dio/latest/) - [x] I have searched for a similar pull request in the [project](https://github.com/cfug/dio/pulls) and found none - [x] I have updated this branch with the latest `main` branch to avoid conflicts (via merge from master or rebase) - [x] I have added the required tests to prove the fix/feature I'm adding - [x] I have updated the documentation (if necessary) - [x] I have run the tests without failures - [x] I have updated the `CHANGELOG.md` in the corresponding package ### Additional context and info (if any) The existing behavior which was somewhat correct got lost in #1405 which was merged in the temporary diox repository. --------- Signed-off-by: Alex Li <[email protected]> Co-authored-by: Alex Li <[email protected]>
NOTE: This goes against the
develop-5.0
branch, since it's a breaking change.New Pull Request Checklist
develop
to avoid conflicts (via merge from master or rebase)Pull Request Description
This significantly improves the inner stacktraces of the
DioError
.