It's 2025, and this is kind of old... but now you can do:
try { // Many types of exceptions can be thrown } catch (CustomException | AnotherCustomException ac) { ... } catch (Exception ex) { ... }
Which is less ugly.