Skip to content

Commit

Permalink
cleanup prettyStackTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
ekmett committed Nov 2, 2019
1 parent 02041fd commit 7974111
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/cadenza/launcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ fun <A> withAnsi(f: () -> A): A {
}

internal fun PolyglotException.prettyStackTrace(trim: Boolean = true) {
val stackTrace = ArrayList<PolyglotException.StackFrame>()
for (s in polyglotStackTrace)
stackTrace.add(s)
val stackTrace = polyglotStackTrace.toMutableList()
if (trim) {
val iterator = stackTrace.listIterator(stackTrace.size)
while (iterator.hasPrevious()) {
Expand All @@ -40,8 +38,8 @@ internal fun PolyglotException.prettyStackTrace(trim: Boolean = true) {
if (isHostException) out.fgRed().a(asHostException().toString())
else out.fgBrightYellow().a(message)
out.reset().a('\n').fgBrightBlack()
for (s in stackTrace) {
out.a(Attribute.ITALIC).a(" at ").a(Attribute.ITALIC_OFF).a(s).a('\n')
stackTrace.forEach {
out.a(Attribute.ITALIC).a(" at ").a(Attribute.ITALIC_OFF).a(it).a('\n')
}
out.reset()
println(out.toString())
Expand Down

0 comments on commit 7974111

Please sign in to comment.