Skip to content

Commit 35c162b

Browse files
committed
Fix crashing issue because of exception when attaching tests
1 parent 70dc6c5 commit 35c162b

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

adapter/src/main/kotlin/org/javacs/ktda/jdi/JDIDebuggee.kt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,22 @@ class JDIDebuggee(
167167
override fun positionOf(location: Location): Position? = sourceOf(location)
168168
?.let { Position(it, location.lineNumber()) }
169169

170-
private fun sourceOf(location: Location): Source? {
171-
val sourcePath = location.sourcePath()
172-
val sourceName = location.sourceName()
173-
174-
return sourcesRoots
175-
.asSequence()
176-
.map { it.resolve(sourcePath) }
177-
.orEmpty()
178-
.mapNotNull { findValidKtFilePath(it, sourceName) }
179-
.firstOrNull()
180-
?.let { Source(
181-
name = sourceName ?: it.fileName.toString(),
182-
filePath = it
183-
) }
184-
}
170+
private fun sourceOf(location: Location): Source? =
171+
try {
172+
val sourcePath = location.sourcePath()
173+
val sourceName = location.sourceName()
174+
175+
sourcesRoots
176+
.asSequence()
177+
.map { it.resolve(sourcePath) }
178+
.orEmpty()
179+
.mapNotNull { findValidKtFilePath(it, sourceName) }
180+
.firstOrNull()
181+
?.let { Source(
182+
name = sourceName ?: it.fileName.toString(),
183+
filePath = it
184+
) }
185+
} catch(exception: AbsentInformationException) {
186+
null
187+
}
185188
}

0 commit comments

Comments
 (0)