Created
October 18, 2021 11:23
-
-
Save s0nerik/cf87c43dee3d7ad8c4f5ecb8728307d8 to your computer and use it in GitHub Desktop.
Dart async error catch example (CORRECT, actually captures the expection)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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