JDK-6474895 : Should support multiple exceptions in a catch block
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-09-25
  • Updated: 2012-01-11
  • Resolved: 2006-09-29
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Java does not allow me to catch exceptions looks like following:

try{
    object.method();
} catch (Exception1, Exception2 e) {
    System.out.println ("You should check the DEVICE_1");
} catch (Exception3, Exception4 e) {
     System.out.println ("You should check the DEVICE_2");
}

JUSTIFICATION :
Sometime, I want to deal some exceptions with the same behaviour. At the current, I have to deal each exception with a catch block. For instance:

try{
    object.method();
} catch (Exception1 e) {
    System.out.println ("You should check the DEVICE_1");
} catch (Exception2 e) {
    System.out.println ("You should check the DEVICE_1");
} catch (Exception3 e) {
     System.out.println ("You should check the DEVICE_2");
} catch (Exception4 e) {
    System.out.println ("You should check the DEVICE_2");
} 

I do the same behaviour with Exception1 and Exception2, and other the same behaviour with Exception3 and Exception4, but I have to declare 4 catch statement.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It will be great if I can write code as described in the Description part.

Comments
EVALUATION Duplicate 4909760.
29-09-2006