aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/printing/Showable.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/printing/Showable.scala')
-rw-r--r--src/dotty/tools/dotc/printing/Showable.scala7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/printing/Showable.scala b/src/dotty/tools/dotc/printing/Showable.scala
index 550d80060..37de053cb 100644
--- a/src/dotty/tools/dotc/printing/Showable.scala
+++ b/src/dotty/tools/dotc/printing/Showable.scala
@@ -5,6 +5,7 @@ import core._
import Contexts._, Texts._, Decorators._
import config.Config.summarizeDepth
+import scala.util.control.NonFatal
trait Showable extends Any {
@@ -20,7 +21,11 @@ trait Showable extends Any {
def fallbackToText(printer: Printer): Text = toString
/** The string representation of this showable element. */
- def show(implicit ctx: Context): String = toText(ctx.printer).show
+ def show(implicit ctx: Context): String =
+ try toText(ctx.printer).show
+ catch {
+ case NonFatal(ex) => s"[cannot display due to $ex, raw string = $toString]"
+ }
/** The summarized string representation of this showable element.
* Recursion depth is limited to some smallish value. Default is