Skip to content

Instantly share code, notes, and snippets.

@thoradam
Last active February 7, 2023 20:18
Show Gist options
  • Save thoradam/31c67d9db64a07a0c60a2cab7749af8e to your computer and use it in GitHub Desktop.
Save thoradam/31c67d9db64a07a0c60a2cab7749af8e to your computer and use it in GitHub Desktop.
fluttering-diamond-1276

fluttering-diamond-1276

Created with <3 with dartpad.dev.

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