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

Disallow try statements without catch or finally block

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-rc-1
    • 1.6-rc-2, 1.5.8, 1.7-beta-1
    • Compiler
    • None

    Description

      Unlike Java, Groovy allows try statements without a catch or finally block:

      class TryWithoutCatchOrFinally {
      static void main(args) {
      try

      { println "hi" }

      }
      }

      Execution of such a try statement just executes the try block (it doesn't swallow exceptions). The following discussion seems to come to the conclusion that it would be better to follow Java and raise a syntax error: http://www.nabble.com/Try-statement-without-catch-or-finally-block-td21542131.html

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            guillaume Guillaume Sauthier
            pniederw Peter Niederwieser
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment