Support Firefox stack format
It doesn't include the exception type and message.
This commit is contained in:
@@ -68,23 +68,26 @@ private class ExceptionTraceBuilder {
|
|||||||
|
|
||||||
private fun Throwable.dumpSelfTrace(indent: String, qualifier: String): Boolean {
|
private fun Throwable.dumpSelfTrace(indent: String, qualifier: String): Boolean {
|
||||||
target.append(indent).append(qualifier)
|
target.append(indent).append(qualifier)
|
||||||
|
val shortInfo = this.toString()
|
||||||
if (hasSeen(this)) {
|
if (hasSeen(this)) {
|
||||||
target.append("[CIRCULAR REFERENCE, SEE ABOVE: ").append(this).append("]\n")
|
target.append("[CIRCULAR REFERENCE, SEE ABOVE: ").append(shortInfo).append("]\n")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
visited.asDynamic().push(this)
|
visited.asDynamic().push(this)
|
||||||
|
|
||||||
var stack = this.asDynamic().stack as String?
|
var stack = this.asDynamic().stack as String?
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
|
val stackStart = stack.indexOf(shortInfo).let { if (it < 0) 0 else it + shortInfo.length }
|
||||||
|
if (stackStart == 0) target.append(shortInfo).append("\n")
|
||||||
if (topStack.isEmpty()) {
|
if (topStack.isEmpty()) {
|
||||||
topStack = stack
|
topStack = stack
|
||||||
topStackStart = this.toString().length
|
topStackStart = stackStart
|
||||||
} else {
|
} else {
|
||||||
stack = dropCommonFrames(stack, this.toString().length)
|
stack = dropCommonFrames(stack, stackStart)
|
||||||
}
|
}
|
||||||
if (indent.isNotEmpty()) {
|
if (indent.isNotEmpty()) {
|
||||||
// indent stack, but avoid indenting exception message lines
|
// indent stack, but avoid indenting exception message lines
|
||||||
val messageLines = 1 + (message?.count { c -> c == '\n' } ?: 0)
|
val messageLines = if (stackStart == 0) 0 else 1 + shortInfo.count { c -> c == '\n' }
|
||||||
stack.lineSequence().forEachIndexed { index: Int, line: String ->
|
stack.lineSequence().forEachIndexed { index: Int, line: String ->
|
||||||
if (index >= messageLines) target.append(indent)
|
if (index >= messageLines) target.append(indent)
|
||||||
target.append(line).append("\n")
|
target.append(line).append("\n")
|
||||||
@@ -93,7 +96,7 @@ private class ExceptionTraceBuilder {
|
|||||||
target.append(stack).append("\n")
|
target.append(stack).append("\n")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
target.append(this.toString()).append("\n")
|
target.append(shortInfo).append("\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
val suppressed = suppressedExceptions
|
val suppressed = suppressedExceptions
|
||||||
|
|||||||
Reference in New Issue
Block a user