| Info | Value | |
| ------------------------------ | ----------------------------------------------------- | ---- |
| Platform Name Flutter | |
| Platform Version Flutter (Channel v1.12.13-hotfixes, v1.12.13+hotfix.8, on Mac OS X 10.15.3
19D76, locale en-US)
| Dio Version 3.0.9
NOTE: I am using VSCode with "All Exceptions" disabled, "Uncaught Exceptions" enabled.
When I perform a Dio().get or Dio().post with a URL that does not exist I receive an Uncaught Exception at the end of DioMixin._dispatchRequest() even though I have a try catch around the call. I have tried numerous combinations of try catch with a simple catch, on DioError, etc. but the uncaught exception continues to occur.
I have recreated with this very simple code fragment. This comes directly from the examples on the Dio github site.
Test One:
Future
try {
Response response = await Dio().post("http://www.somebadurl.com");
print(response);
} catch (e) {
print(e);
}
}
Exception has occurred.
DioError (DioError [DioErrorType.DEFAULT]: SocketException: Failed host lookup: 'www.somebadurl.com' (OS Error: nodename nor servname provided, or not known, errno = 8))
Test Two:
Future
try {
//404
await Dio().get("https://wendux.github.io/xsddddd");
} on DioError catch (e) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx and is also not 304.
if (e.response != null) {
print(e.response.data);
print(e.response.headers);
print(e.response.request);
} else {
// Something happened in setting up or sending the request that triggered an Error
print(e.request);
print(e.message);
}
} catch (e) {
print("simple catch $e");
}
}
Exception has occurred.
DioError (DioError [DioErrorType.RESPONSE]: Http status error [404])
Stack Trace:
DioMixin._dispatchRequest (/Users/keithblack/.pub-cache/hosted/pub.dartlang.org/dio-3.0.9/lib/src/dio.dart:963)
DioMixin._dispatchRequest (/Users/keithblack/.pub-cache/hosted/pub.dartlang.org/dio-3.0.9/lib/src/dio.dart:0)
_Closure.call (dart:core-patch/function.dart:0)
DioMixin._request._interceptorWrapper.
_Closure.call (dart:core-patch/function.dart:0)
DioMixin.checkIfNeedEnqueue (/Users/keithblack/.pub-cache/hosted/pub.dartlang.org/dio-3.0.9/lib/src/dio.dart:1117)
DioMixin._request._interceptorWrapper.
new Future.
_rootRun (dart:async/zone.dart:1122)
_rootRun (dart:async/zone.dart:0)
_CustomZone.run (dart:async/zone.dart:1023)
_CustomZone.runGuarded (dart:async/zone.dart:925)
_CustomZone.bindCallbackGuarded.
_rootRun (dart:async/zone.dart:1126)
_rootRun (dart:async/zone.dart:0)
_CustomZone.run (dart:async/zone.dart:1023)
_CustomZone.bindCallback.
Timer._createTimer.
_Closure.call (dart:core-patch/function.dart:0)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions.
This issue is still occurring with no resolution (or response from anyone).
Please let me know if you have a solution to my issue above.
Any solution???
I have the same problem, but I noticed that the problem happens only in the debugging mode, so if you run your app without debugging (flutter run) or in release mode, the app will run normally and it will catch the exceptions, it is strange problem, I wish to get the solution very soon
I have the same problem, but I noticed that the problem happens only in the debugging mode, so if you run your app without debugging (flutter run) or in release mode, the app will run normally and it will catch the exceptions, it is strange problem, I wish to get the solution very soon
Yeah, that's right! The problem only occurs while debugging. But it's annoying since the application continues pausing while you're debugging on device or emulator.
You can unchecked the uncaught exception if you use VS Code
On Wed, 3 Jun 2020, 8:34 pm Gustavo Figueira, notifications@github.com
wrote:
I have the same problem, but I noticed that the problem happens only in
the debugging mode, so if you run your app without debugging (flutter run)
or in release mode, the app will run normally and it will catch the
exceptions, it is strange problem, I wish to get the solution very soonYeah, that's right! The problem only occurs while debugging. But it's
annoying since the application continues pausing while you're debugging on
device or emulator.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/flutterchina/dio/issues/730#issuecomment-638345552,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AIG5H7PZ7OQNSYN7ZI6DEHLRU2CTVANCNFSM4MCY5WDQ
.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions.
This is still an issue. The only way to get around it when debugging is to disable uncaught exceptions in the debugger. This is not desirable because when I receive an uncaught exception in another part of my code during development I want the exception to be trapped by the debugger.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions.
Most helpful comment
This is still an issue. The only way to get around it when debugging is to disable uncaught exceptions in the debugger. This is not desirable because when I receive an uncaught exception in another part of my code during development I want the exception to be trapped by the debugger.