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

log error/throw exception in Builder

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-beta-8
    • 1.0-beta-10
    • ast builder
    • None
    • All

    Description

      In a builder, if the number or type of arguments is wrong, they are silently ignored. Instead, it would be better to either log an error message or (preferably) throw an exception.

      In groovy/util/BuilderSupport.java, line 88, is doInvokeMethod(). The changes should go in there: have a default for the switch statement, plus in case 2:, the last "if" should have an else for the error.

      Alternately, groovy could support foo(object, key:value) in addition to foo(key:value, object), which it already supports. At least in SwingBuilder, that's more natural to me. e.g. now I can declare a label:

      label("Blah")

      If I want to add a constraint it would be natural to write:

      label("Blah", constriants:SOUTH)

      Now I have to add a text: in front of the text:

      label(text:"Blah", constraints:SOUTH)

      Attachments

        1. BuilderSupport.diff
          2 kB
          Martin C. Martin
        2. BuilderSupportTest.diff
          2 kB
          Martin C. Martin

        Activity

          People

            jstrachan James Strachan
            mcspanky Martin C. Martin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: