Created with <3 with dartpad.dev.
Created
January 30, 2023 11:57
-
-
Save Jimmybee/36697ecbbbc30b55aa5af9eff2f1f5fe to your computer and use it in GitHub Desktop.
slick-villa-7158
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
class MyException implements Exception { | |
final String title; | |
MyException(this.title); | |
} | |
void main() { | |
try { | |
print('Doing thing'); | |
throw MyException('Catch me'); | |
} on MyException catch(e) { | |
print(e.title); | |
} catch (e) { | |
print('Final catch?'); | |
} | |
print(''); | |
try { | |
try { | |
print('Doing thing 2'); | |
throw MyException('Catch me'); | |
} on MyException catch(e) { | |
print(e.title); | |
rethrow; | |
} catch (e) { | |
print('Final catch INSIDE Rethrow'); | |
} | |
} catch (e) { | |
print('Final catch OUTSIDE Rethrow'); | |
} | |
print(''); | |
try { | |
print('Doing thing 3'); | |
throw MyException('Catch me'); | |
} catch (e) { | |
print('Final catch without checking My Exception'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment