Advertisement
lobaev

Untitled

Aug 4th, 2022
1,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.36 KB | None | 0 0
  1. fun Throwable.lastCause(): Throwable {
  2.     val dejaVu = Collections.newSetFromMap(IdentityHashMap<Throwable, Boolean>())
  3.     dejaVu.add(this)
  4.     var curThrowable = this
  5.     while (curThrowable.cause != null && !dejaVu.contains(curThrowable.cause)) {
  6.         curThrowable = curThrowable.cause!!
  7.         dejaVu.add(curThrowable)
  8.     }
  9.     return curThrowable
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement