Skip to content

Commit 8185355

Browse files
Merge pull request #661 from KasperskyLab/ISSUE-639-Attach-original-exception
ISSUE-639: Attach original exception as a suppressed one
2 parents 43ab869 + af15496 commit 8185355

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kaspresso/src/main/kotlin/com/kaspersky/kaspresso/failure/FailureLoggingProviderImpl.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class FailureLoggingProviderImpl(
7777
* @return transformed [error].
7878
*/
7979
private fun Throwable.describedWith(viewMatcher: Matcher<View>?): Throwable {
80-
return when {
80+
val newError = when {
8181
this is PerformException -> {
8282
PerformException.Builder()
8383
.from(this)
@@ -93,7 +93,11 @@ class FailureLoggingProviderImpl(
9393
RuntimeException(message.toString())
9494
}
9595
else -> this
96-
}.apply { stackTrace = Thread.currentThread().stackTrace }
96+
}
97+
newError.stackTrace = Thread.currentThread().stackTrace
98+
newError.addSuppressed(this)
99+
100+
return newError
97101
}
98102

99103
private fun isWebViewException(throwable: Throwable): Boolean {

0 commit comments

Comments
 (0)