Replies: 2 comments 3 replies
-
Would the |
Beta Was this translation helpful? Give feedback.
-
The ideal solution would be obviously a native stacktrace solution that traces back to the user call. Currently, the developer only sees the useful stacktrace if there is a proper import 'package:dio/dio.dart';
void main() async {
try {
await Dio().get('https://google.com/abc');
} catch (e, st) {
print('Internal stacktrace of dio:');
print(st);
if (e is DioException) {
print('The actual helpful stacktrace:');
print(e.stackTrace);
}
}
} This is not a big deal if the developer depends on dio directly but this does not work for general purpose libraries that do not have a dependency on Dio. I think the following should be ideal:
But we somehow lose the suspension information (maybe due to https://stackoverflow.com/questions/68101983/most-valuable-stacktrace-is-lost-when-using-completer). |
Beta Was this translation helpful? Give feedback.
-
As this problem came up again in a PR, maybe we can explore some options for dio 6.0.0 here.
Due to async gaps we don't have exactly one stacktrace that contains everything.
We can currently only have one stacktrace for a
DioException
and we previously decided to use the stacktrace that points to the the actual dio call (get/put etc.) instead of the the stacktrace that points deeper into the internals. This stacktrace is more helpful to the user in figuring out which call causes the exception.Do we want to make both stacktraces accessible?
DioException
again in someDioExceptionCause
class and add the original stacktrace there.Expando
to attach the original stacktrace without a breaking change and provide a new functionDioException.extractCause(Function(Object? error, StackTrace? stack))
to access it.Beta Was this translation helpful? Give feedback.
All reactions