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

try..catch can't be in the middle of a method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-3
    • 1.1-beta-1
    • None
    • None

    Description

      I wrote a class like this:
      class ScoreChangeRecorder {
      ...
      public ScoreChangeRecorder(date) {
      try {
      def String DROP_TABLE = """"
      DROP TABLE balance_change_log_${date}
      """
      sql.executeUpdate(DROPTABLE)
      } catch (Exception e) {
      }
      this.date = date
      dropTable()
      def String CREATE_TABLE = """
      CREATE TABLE balance_change_log_${date}
      (
      id serial NOT NULL PRIMARY KEY,
      user_id int8,
      money_point int4 NOT NULL,
      balance int8,
      reason text,
      change_type text,
      change_time timestamp NOT NULL,
      raceid text
      )
      """
      sql.executeUpdate(CREATE_TABLE)
      sql.commit()
      STATEMENT = """
      insert into balance_change_log_${date}(user_id, money_point, balance, reason, change_type, change_time, raceid)
      values(?, ?, ?, ?, ?, ?, ?)
      """
      ps = sql.connection.prepareStatement(STATEMENT)
      }

      public void finishWork() {
      def String CREATE_INDEX = """
      CREATE INDEX idx_change_log_${date} on balance_change_log_${date}(user_id)
      """
      sql.executeUpdate(CREATE_INDEX)
      sql.commit()
      }
      ...

      When I run the script, I got a confusing error: Verify error: Illegal exception range in finishWork!
      If I just wrapped the try..catch block in another method, everything run ok.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            renewdoit Luo Tian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: