-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
DioException.toString()
should contain the request information
#1949
Comments
The request information is available via |
The
|
DioException
should contain the request informationDioException.toString()
should contain the request information
@iota9star Are you willing to contribute this as a PR? |
Can we always print the URL, are there any possible privacy concerns if we omit query parameters? |
Appropriately outputting additional information does not pose much of a problem. Request method, request path and such do not have major privacy issues. Error messages are controlled by developers, and leaks are only individual developer's problems. Of course we can also try printing exception information at different levels through configuration. |
This is too difficult for me. |
Doesn't writing your own error log interceptor allow this? dio/dio/lib/src/interceptor.dart Lines 200 to 206 in 4d7ea68
|
@ueman Hi Jonas, would this be a valid approach? Any concerns? class ErrorMessageRewritingInterceptor extends Interceptor {
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
final errWithHelpfulMessage =
err.copyWith(message: '<some helpful message for debugging>');
super.onError(errWithHelpfulMessage, handler);
}
} |
I've filed 2 PRs to find out if there is a better answer for the issue. Please vote or add comments if you'd like to. |
Request Statement
When printing exception information, it is impossible to quickly locate the source of the request. Here are some examples:
DioException [connection timeout]: The request connection took longer than 0:00:30.000000. It was aborted.
The exception message only shows that a connection timeout occurred, but does not provide any information about which request timed out. This makes it difficult to quickly identify the problematic request when debugging.
Some additional context that would be useful:
The URL of the request
The HTTP method (GET, POST, etc)
Any identifiers like request ID
So a more helpful exception could be:
DioException [connection timeout]: GET https://example.com/api/v1/users took longer than 30s and was aborted.
By including details like the URL and request method in the exception, it becomes much faster to pinpoint where the problem is occurring.
Solution Brainstorm
No response
The text was updated successfully, but these errors were encountered: