cleanStackTrace() now returns itself.

This commit is contained in:
Robinson 2023-09-08 13:20:24 +02:00
parent 78ae3a38e4
commit dafcc97eac
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
1 changed files with 4 additions and 2 deletions

View File

@ -41,13 +41,13 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
*
* Neither of these are useful in resolving exception handling from a users perspective, and only clutter the stacktrace.
*/
fun Throwable.cleanStackTrace(adjustedStartOfStack: Int = 0) {
fun Throwable.cleanStackTrace(adjustedStartOfStack: Int = 0): Throwable {
// we never care about coroutine stacks, so filter then to start with.
val origStackTrace = this.stackTrace
val size = origStackTrace.size
if (size == 0) {
return
return this
}
val stackTrace = origStackTrace.filterNot {
@ -93,6 +93,8 @@ internal class ListenerManager<CONNECTION: Connection>(private val logger: KLogg
// keep just one, since it's a stack frame INSIDE our network library, and we need that!
this.stackTrace = stackTrace.copyOfRange(0, 1)
}
return this
}
/**