Skip to content

Instantly share code, notes, and snippets.

@s0nerik
Created October 18, 2021 11:23
Show Gist options
  • Save s0nerik/cf87c43dee3d7ad8c4f5ecb8728307d8 to your computer and use it in GitHub Desktop.
Save s0nerik/cf87c43dee3d7ad8c4f5ecb8728307d8 to your computer and use it in GitHub Desktop.
Dart async error catch example (CORRECT, actually captures the expection)
Future<void> main() async {
await test();
}
Future<void> test() async {
try {
return await errorGenerator();
} catch (e) {
print('!!!CAPTURED ERROR!!!');
} finally {
print('!!!FINALLY!!!');
}
}
Future<void> errorGenerator() async {
throw Exception('hello');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment