Skip to content

Commit bea72e5

Browse files
committed
Add setting to show error stacktraces during printing
1 parent 5ff14bd commit bea72e5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class ScalaSettings extends Settings.SettingGroup {
101101
val YplainPrinter = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.")
102102
val YprintSyms = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.")
103103
val YprintDebug = BooleanSetting("-Yprint-debug", "when printing trees, print some extra information useful for debugging.")
104+
val YshowPrintErrors = BooleanSetting("-Yshow-print-errors", "don't suppress exceptions thrown during tree printing.")
104105
val YtestPickler = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler")
105106
val YcheckReentrant = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.")
106107
val YkeepComments = BooleanSetting("-Ykeep-comments", "Keep comments when scanning source files.")

compiler/src/dotty/tools/dotc/printing/Formatting.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ object Formatting {
3131
case arg: Showable =>
3232
try arg.show
3333
catch {
34-
case NonFatal(ex) if !ctx.mode.is(Mode.PrintShowExceptions) =>
34+
case NonFatal(ex)
35+
if !ctx.mode.is(Mode.PrintShowExceptions) &&
36+
!ctx.settings.YshowPrintErrors.value =>
3537
s"[cannot display due to $ex, raw string = $toString]"
3638
}
3739
case _ => arg.toString

0 commit comments

Comments
 (0)