Skip to content

Instantly share code, notes, and snippets.

@Jimmybee
Created January 30, 2023 11:57
Show Gist options
  • Save Jimmybee/36697ecbbbc30b55aa5af9eff2f1f5fe to your computer and use it in GitHub Desktop.
Save Jimmybee/36697ecbbbc30b55aa5af9eff2f1f5fe to your computer and use it in GitHub Desktop.
slick-villa-7158
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