Consider this source code:
---
try {
} catch (IllegalStateException | java.io.IOException ex) {
}
---
In jshell, this will produce the following error:
| Error:
| exception java.io.IOException is never thrown in body of corresponding try statement
| } catch (IllegalStateException | java.io.IOException ex) {}
| ^-------------------------------------------------------^
Seems the span of the error is incovenient - there is no issue with the catch block as such, it is just with a single exception in the multi-catch.
A better error span would be like:
| Error:
| exception java.io.IOException is never thrown in body of corresponding try statement
| } catch (IllegalStateException | java.io.IOException ex) {}
| ^-----------------^
---
try {
} catch (IllegalStateException | java.io.IOException ex) {
}
---
In jshell, this will produce the following error:
| Error:
| exception java.io.IOException is never thrown in body of corresponding try statement
| } catch (IllegalStateException | java.io.IOException ex) {}
| ^-------------------------------------------------------^
Seems the span of the error is incovenient - there is no issue with the catch block as such, it is just with a single exception in the multi-catch.
A better error span would be like:
| Error:
| exception java.io.IOException is never thrown in body of corresponding try statement
| } catch (IllegalStateException | java.io.IOException ex) {}
| ^-----------------^