Skip to content

Commit 82a5966

Browse files
committed
add nodejs stacktrace test
1 parent 34b6e04 commit 82a5966

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/commonMain/kotlin/spp.protocol/artifact/exception/LiveStackTrace.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ class LiveStackTrace(
8383

8484
fun fromString(data: String): LiveStackTrace? {
8585
return when {
86+
nodeFrameRegex.containsMatchIn(data) -> extractNodeStackTrace(data)
8687
frameRegex.containsMatchIn(data) -> extractJvmStackTrace(data)
8788
pythonFrameRegex.containsMatchIn(data) -> extractPythonStackTrace(data)
88-
nodeFrameRegex.containsMatchIn(data) -> extractNodeStackTrace(data)
8989
else -> null
9090
}
9191
}
@@ -99,9 +99,12 @@ class LiveStackTrace(
9999
val line = el.groupValues[3].toInt()
100100
val column = el.groupValues[4].toInt()
101101

102-
elements.add(LiveStackTraceElement(method, "$file:$line"))
102+
elements.add(LiveStackTraceElement(method, "$file:$line", column))
103103
}
104-
return LiveStackTrace("n/a", "n/a", elements)
104+
val firstLine = data.split("\n").first()
105+
val exceptionType = firstLine.split(":").firstOrNull() ?: "n/a"
106+
val message = firstLine.split(": ").drop(1).firstOrNull() ?: "n/a"
107+
return LiveStackTrace(exceptionType, message, elements)
105108
}
106109

107110
private fun extractPythonStackTrace(data: String): LiveStackTrace {

src/commonMain/kotlin/spp.protocol/artifact/exception/LiveStackTraceElement.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import spp.protocol.instrument.variable.LiveVariable
3030
data class LiveStackTraceElement(
3131
val method: String,
3232
val source: String,
33+
val column: Int? = null,
3334
val variables: MutableList<LiveVariable> = mutableListOf(),
3435
var sourceCode: String? = null
3536
) {

0 commit comments

Comments
 (0)