I have a strange problem,I used a try catch to catch the error, but it didn't work。
void main() {
testException();
}
void testException() {
print("start");
try {
print("try");
testThrow();
} on Exception catch (e) {
print("catch exceptoin:$e");
}
print("end");
}
void testThrow() {
throw Exception("this is exception");
}
The execution result:
Is there something I didn't turn on?
add:
After several tests,I Found In the error stack,There is an error:
Not found “dart:isolate/runtime/libisolate_patch.dart”: <source not available>。
I'm trying to import it in code,The prompt error is as follows:
Launching lib/main.dart on iPhone X in debug mode...
Compiler message:
lib/main.dart:6:8: Error: Not found: 'dart:isolate/runtime/libisolate_patch.dart'
import 'dart:isolate/runtime/libisolate_patch.dart';
^
Unhandled exception:
Unsupported operation: Cannot extract a file path from a org-dartlang-untranslatable-uri URI
#0 _Uri.toFilePath (dart:core/uri.dart:2617:7)
#1 _writeDepfile (package:vm/frontend_server.dart:682:32)
<asynchronous suspension>
#2 FrontendCompiler.compile (package:vm/frontend_server.dart:363:15)
<asynchronous suspension>
#3 _FlutterFrontendCompiler.compile (package:frontend_server/server.dart:31:22)
<asynchronous suspension>
#4 starter (package:frontend_server/server.dart:133:27)
<asynchronous suspension>
#5 main (file:///b/build/slave/Mac_Engine/build/src/flutter/frontend_server/bin/starter.dart:8:30)
<asynchronous suspension>
#6 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:287:32)
#7 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
Compiler failed on /Users/xohome/Documents/shx158/workspace/app/sxapp/lib/main.dart
Error launching application on iPhone X.
Exited (sigterm)
flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale zh-Hans-CN)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.io/setup/#android-setup for detailed instructions).
If Android SDK has been installed to a custom location, set $ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.4)
[✓] VS Code (version 1.30.1)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
The yellow arrow on line 22 in the picture shows that the debugger is paused at that line. The stack trace on the left shows the same thing: The program is currently in the testThrow
method.
The debugger seems to be set to pause on all throws, since there is no breakpoint registered on line 22. There should be a panel called "breakpoints" (at least that's it's name in English) with two checkboxes below the "stack traces" panel on the left. The top check-box is called "All exceptions" and when checked, the debugger will break at the throw.
You need to continue the program to see what happens later. You should be able to do so by pressing F5. Alternatively clear the checkbox that makes it break on all throws and restart the program.