You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the recent introduction of pattern matching in Dart, it would be beneficial to extend this feature to error handling, enabling more expressive and concise error handling mechanisms.
This proposal aims to leverage pattern matching syntax for catching exceptions, providing developers with more flexibility and clarity in error handling while aiming to solve #112.
Straw man syntax:
classFooExceptionimplementsException {
finalString msg1;
FooException(this.msg1);
}
classBarExceptionimplementsException {
finalString msg2;
BarException(this.msg2);
}
voidmain() {
try {
throwFooException('Hi!');
} catch (e caseFooException() ||BarException(), StackTrace s) {
print('Exception is FooException or BarException');
} catch (e caseFooException(msg1:final m) ||BarException(msg2:final m) when m.length >0, s) {
print(m);
}
}
Since there are no checked exceptions in Dart, we cannot exhaustively check for exceptions.
The text was updated successfully, but these errors were encountered:
With the recent introduction of pattern matching in Dart, it would be beneficial to extend this feature to error handling, enabling more expressive and concise error handling mechanisms.
This proposal aims to leverage pattern matching syntax for catching exceptions, providing developers with more flexibility and clarity in error handling while aiming to solve #112.
Straw man syntax:
Since there are no checked exceptions in Dart, we cannot exhaustively check for exceptions.
The text was updated successfully, but these errors were encountered: