Skip to content

Instantly share code, notes, and snippets.

@madmag77
Created March 2, 2021 06:51
Show Gist options
  • Save madmag77/3defca3408ec2427612562da74323aad to your computer and use it in GitHub Desktop.
Save madmag77/3defca3408ec2427612562da74323aad to your computer and use it in GitHub Desktop.
[Dart article] Async code exceptions 6
await Future.delayed(Duration(seconds: 1), () {
print('Its fie so far');
}).then((value) {
print('Then started');
throw 'random exception';
}).catchError((error) {
print('Cant divide to zero');
}, test: (e) => e is IntegerDivisionByZeroException).catchError((error) {
print('All other exceptions: $error');
}, test: (e) => true).whenComplete(() {
print('Clean-up done');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment