Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1984

Shorther syntax for catching multiple exceptions at once

    XMLWordPrintableJSON

Details

    Description

      John Wilson suggested this improved syntax for catching several exceptions at once:

      This has been suggested for Java
      http://members.capmac.org/~orb/blog.cgi/tech/java/Better_exception_sy.html

      I would have thought it's trivial to do in Groovy

      try { 
          Field field = someClass.getDeclaredField(someField); 
          someValue = field.getInt(Barcode.class); 
      } catch (SecurityException, NoSuchFieldException e) { 
          // do something else with the exception 
      }
      

      Attachments

        1. Added_support_for_multicatch_(GROOVY-1984).patch
          13 kB
          Cédric Champeau
        2. Support_for_final_modifier.patch
          2 kB
          Cédric Champeau

        Activity

          People

            melix Cédric Champeau
            guillaume Guillaume Sauthier
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: