Programming languages โ€‹โ€‹with Java-7 try-multiple-catch block equivalent?

Java 7 has a new way to catch multiple exceptions in a single catch , as shown below.

 try { //stuff that causes one or more of the exceptions below. } catch (IOException | IllegalArgumentException | IndexOutOfRangeException ex) { //one of the above exceptions was thrown and caught //this code block will run if any of the above exceptions was caught } 

What other programming languages, if any, have a similar way of catching multiple exceptions in one block or removing the need to use a catch for each exception? How do these languages โ€‹โ€‹implement this catch of several exceptions?

+4
source share
2 answers

The Ada programming language allows you to capture several exception blocks, but I have no idea how this is implemented, but it should be really interesting to know, because Ada is VERY strongly typed. You can check the syntax here: Ada Annotated Reference Guide

+1
source

Javascript requires that you can catch all exceptions in a single catch since it was not statically injected.

-1
source

All Articles