Created
March 5, 2021 10:10
-
-
Save madmag77/3a9baff01f0759a46d76d0338fbd31af to your computer and use it in GitHub Desktop.
[Dart article] Guarded zones 2
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
print('Current zone start in: ${Zone.current.toString()}'); | |
runZonedGuarded(() { | |
print( | |
'Current zone inside runZoned: ${Zone.current.toString()} with name ${Zone.current['ZoneName']}'); | |
Timer.run(() { | |
print('Timer runs.'); | |
throw Exception('[Timer] Bad thing happens!'); | |
}); | |
runZonedGuarded( | |
() { | |
print( | |
'Current zone (1) inside runZoned: ${Zone.current.toString()} with name ${Zone.current['ZoneName']}'); | |
Timer.run(() { | |
print('Timer 1 runs. '); | |
throw Exception('[Timer 1] Bad thing happens!'); | |
}); | |
}, | |
(e, s) { | |
print( | |
'Current zone (1) inside catch: ${Zone.current.toString()} with name ${Zone.current['ZoneName']}'); | |
print('Exception handled (1) $e, \n$s'); | |
}, | |
zoneValues: {'ZoneName': 'Second zone'}, | |
); | |
print('Everything is fine!'); | |
}, (e, s) { | |
print( | |
'Current zone inside catch: ${Zone.current.toString()} with name ${Zone.current['ZoneName']}'); | |
print('Exception handled $e, \n$s'); | |
}, zoneValues: {'ZoneName': 'First zone'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment