From 2fc528e0887b46a8dea403c1f8620ca8967c4b42 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 24 Aug 2013 04:20:44 -0700 Subject: SI-7781 REPL stack trunc shows cause The handy stack trace truncation in REPL doesn't show cause like a regular trace. This commit fixes that and also adds the usual indicator for truncation, viz, "... 33 more". The example from the ticket produces: ``` scala> rewrapperer java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: Point of failure at .rewrapper(:9) at .rewrapperer(:10) ... 32 elided Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Point of failure at .wrapper(:8) ... 34 more Caused by: java.lang.RuntimeException: Point of failure at .sample(:7) ... 35 more ``` Suppressed exceptions on Java 7 are handled reflectively. ``` java.lang.RuntimeException: My problem at scala.tools.nsc.util.StackTraceTest.repressed(StackTraceTest.scala:56) ... 27 elided Suppressed: java.lang.RuntimeException: Point of failure at scala.tools.nsc.util.StackTraceTest.sample(StackTraceTest.scala:29) at scala.tools.nsc.util.StackTraceTest.repressed(StackTraceTest.scala:54) ... 27 more ``` --- test/files/run/repl-trim-stack-trace.scala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/files') diff --git a/test/files/run/repl-trim-stack-trace.scala b/test/files/run/repl-trim-stack-trace.scala index bbf46f2f19..db42b37fdd 100644 --- a/test/files/run/repl-trim-stack-trace.scala +++ b/test/files/run/repl-trim-stack-trace.scala @@ -13,6 +13,7 @@ f: Nothing scala> f java.lang.Exception: Uh-oh at .f(:7) + ... 69 elided scala> def f = throw new Exception("") f: Nothing @@ -20,6 +21,7 @@ f: Nothing scala> f java.lang.Exception: at .f(:7) + ... 69 elided scala> def f = throw new Exception f: Nothing @@ -27,7 +29,13 @@ f: Nothing scala> f java.lang.Exception at .f(:7) + ... 69 elided scala> """ + // remove the "elided" lines because the frame count is variable + lazy val elided = """\s+\.{3} (?:\d+) elided""".r + def filtered(lines: Seq[String]) = lines filter { case elided() => false ; case _ => true } + override def eval() = filtered(super.eval().toSeq).iterator + override def expected = filtered(super.expected).toList } -- cgit v1.2.3