Created with <3 with dartpad.dev.
Last active
February 7, 2023 20:18
-
-
Save thoradam/31c67d9db64a07a0c60a2cab7749af8e to your computer and use it in GitHub Desktop.
fluttering-diamond-1276
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<int> onErrorTrickery() { | |
var f = Future<int>.error("original error"); | |
f.onError ((Object e, StackTrace st) { | |
print("onError callback running"); | |
throw "you cannot catch this error"; | |
}); | |
return f; | |
} | |
Future<void> secretError( ) async { | |
try { | |
await onErrorTrickery(); | |
} catch (e) { | |
print("caught original error: $e"); | |
} | |
} | |
void main() async { | |
try { | |
await secretError(); | |
print("should run"); | |
} catch (e) { | |
print("will never print, cannot catch error"); | |
} | |
print("should also run"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment