dart-lang / dart-lang/language
Syntax catching multiple exceptions in a single on block
Open
request
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
In many cases I only care what type of exception I'm getting.
I don't care about the exception at-most I might want to do a `e.toString()`.
**Example:**
```dart
for (int i = 0; i < retries; i++) {
try {
return networkOperation().timeout(Duration(seconds: 5));
} on SocketException, TimeoutException {
continue;
}
}
```
This isn't critical at all, I was just surprised it didn't work already.
It's trivial to duplicate the block handling the exception, or write a function that accepts a list of types to ignore.
Please close if there is some complication to this that I don't see :)
Contributor guide
Assessment
This issue has not been assessed yet.