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

throwing exception within each() closure gets changed to InvokerInvocationException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-beta-10
    • None
    • None
    • mac os x 10.3.4

    Description

      In an effort to create a construct to allow breaking from a closure-based iterator, I ran into this problem. Here is the code:

      class MyException extends Exception {}

      break_closure =

      { throw new MyException() }

      breakable = {
      try

      { it() }

      catch(MyException e)

      { println "got my exception!" }

      }

      list = [1,2,-1,3]

      breakable {
      list.each

      { if(it == -1) break_closure() else println it }

      }

      This bombs with an InvokerInvocationException. I would have assumed that the exception I threw would get propogated upward, but instead it gets transformed into a different exception along the way.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            johnstump John Stump
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: