This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Accessing caught exception from Intellij debuger

1 reply
Haim Ashkenazi
Joined: 2009-05-13,
User offline. Last seen 42 years 45 weeks ago.
Hi

I'm a complete scala newb so I hope this is not a stupid question :)

I'm trying to write some unit tests with scala (using scalatest) and I have a problem I want to check in the debugger.

Here is the code I'm checking:

  def withFixture(testFunction: (Session) => Unit) {
    // get a new session
    val s = getNewSession()
    s.beginTransaction()

    // now run the testing code
    try {
      testFunction(s)
      s.getTransaction.commit()
    }
    catch {
      case e =>
        // cleanup
        s.getTransaction().rollback()
        throw e
    }
  }

I've added a breakopint in the last "catch" line (throw e). now the debugger stops at this line, I can access all variables except the exception (e). I don't have any "e" object. only "s", "this" and "testFunction". Even running e.printStackTrace() in the evaluation window doesn't work ("there's no such local variable e").

Is it a bug or maybe I have to access it differently?

Thaks in advance

--
Haim
Haim Ashkenazi
Joined: 2009-05-13,
User offline. Last seen 42 years 45 weeks ago.
Re: Accessing caught exception from Intellij debuger
Hi

Here's an update:
If I assign the exception to val:

    catch {
      case e =>
        // cleanup
        s.getTransaction().rollback()
       val v = e
        throw e
    }

Then I can access the exception through the "v" val.

Maybe it's a bug in the scala plugin. Any ideas?

Bye

On Wed, May 13, 2009 at 7:16 AM, Haim Ashkenazi <haim.ashkenazi@gmail.com> wrote:
Hi

I'm a complete scala newb so I hope this is not a stupid question :)

I'm trying to write some unit tests with scala (using scalatest) and I have a problem I want to check in the debugger.

Here is the code I'm checking:

  def withFixture(testFunction: (Session) => Unit) {
    // get a new session
    val s = getNewSession()
    s.beginTransaction()

    // now run the testing code
    try {
      testFunction(s)
      s.getTransaction.commit()
    }
    catch {
      case e =>
        // cleanup
        s.getTransaction().rollback()
        throw e
    }
  }

I've added a breakopint in the last "catch" line (throw e). now the debugger stops at this line, I can access all variables except the exception (e). I don't have any "e" object. only "s", "this" and "testFunction". Even running e.printStackTrace() in the evaluation window doesn't work ("there's no such local variable e").

Is it a bug or maybe I have to access it differently?

Thaks in advance

--
Haim



--
Haim

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland