From 32abb018618ef066aab6b9b9881f6d3cbc4a7d41 Mon Sep 17 00:00:00 2001 From: Him188 Date: Wed, 19 Feb 2020 18:03:37 +0800 Subject: [PATCH] Fix tryNTimes --- .../commonMain/kotlin/net.mamoe.mirai/utils/tryNTimes.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/tryNTimes.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/tryNTimes.kt index 57f418797..c6b6884d0 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/tryNTimes.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/tryNTimes.kt @@ -24,8 +24,7 @@ inline fun tryNTimes(repeat: Int, block: (Int) -> R): R { } catch (e: Throwable) { if (lastException == null) { lastException = e - } - lastException!!.addSuppressed(e) + } else lastException!!.addSuppressed(e) } } @@ -43,8 +42,7 @@ inline fun tryNTimesOrNull(repeat: Int, block: (Int) -> R): R? { } catch (e: Throwable) { if (lastException == null) { lastException = e - } - lastException!!.addSuppressed(e) + } else lastException!!.addSuppressed(e) } } @@ -63,8 +61,7 @@ inline fun tryNTimesOrException(repeat: Int, block: (Int) -> R): Throwable? } catch (e: Throwable) { if (lastException == null) { lastException = e - } - lastException!!.addSuppressed(e) + } else lastException!!.addSuppressed(e) } }