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

Exception in "finally" not caught by outer "try"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.4.8
    • 2.4.10
    • Compiler
    • None
    • linux

    Description

      I would expect the following code to print `caughtt`:
      ```
      groovy -e 'try { try

      { true; }

      finally

      { 1 / 0 }

      } catch (e)

      { println "caughtt" }

      '
      ```

      But instead, it prints:
      ```
      Caught: java.lang.ArithmeticException: Division by zero
      java.lang.ArithmeticException: Division by zero
      at script_from_command_line.run(script_from_command_line:1)
      ```

      Why is the exception, thrown by the `finally`, not being caught by the outer try/catch?

      Attachments

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              csilvers Craig Silverstein
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: