title: How to get stack trace of an exception in Scala to print it?
body: <p>In a program of mine I'd like to catch all exceptions and explicitly print them (to be able to proceed with finally while still seeing exceptions).</p>
  
  <p>So I've tried this:</p>
  
  <pre>
  <code>
  try {
    ...
  }
  catch {
    case ex : Exception => {
      println ("\n" + ex)
      println ("\n" + ex.getStackTrace + "\n")
    }
  }
  finally {
    ...
  }
  </code>
  </pre>
  
  <p>But this (using getStackTrace) itself causes "java.lang.OutOfMemoryError: PermGen space". What am I doing wrong? I am sure I have plenty of free JVM heap memory free before getting this (as I've tried causing an exception in the very beginning of the program).</p>