Skip to content

Instantly share code, notes, and snippets.

@PlugFox
Created November 7, 2024 17:55
Show Gist options
  • Save PlugFox/675bdaf8ae604989e1dc7959abddbfd5 to your computer and use it in GitHub Desktop.
Save PlugFox/675bdaf8ae604989e1dc7959abddbfd5 to your computer and use it in GitHub Desktop.
Completer throws an error to the zone.
/*
* Completer throws an error to the zone.
* https://gist.github.com/PlugFox/675bdaf8ae604989e1dc7959abddbfd5
* https://dartpad.dev?id=675bdaf8ae604989e1dc7959abddbfd5
* Mike Matiunin <[email protected]>, 07 November 2024
*/
// ignore_for_file: cascade_invocations, avoid_print
import 'dart:async';
void main() => runZonedGuarded<void>(() {
try {
final completer = Completer<void>();
/* completer.future.ignore() */
completer.completeError(
Exception('Fake error'),
StackTrace.empty,
);
} on Object {
print('Not happening');
}
}, (error, stackTrace) {
print('Caught error: $error');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment