Should support multiple exceptions in a catch block

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P5
    • None
    • Affects Version/s: 6
    • Component/s: specification
    • x86
    • windows_xp

      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.

            Assignee:
            Iris Clark
            Reporter:
            Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: