Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaodice committed Nov 18, 2022
1 parent b9b2b51 commit ee68f39
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,17 @@ internal abstract class JvmPluginInternal(

val except = try {
javaClass.getDeclaredAnnotation(ConsoleJvmPluginFuncCallbackStatusExcept.OnEnable::class.java)
}catch(e: Throwable){
} catch (e: Throwable) {
null
}

kotlin.runCatching {
onEnable()
}.fold(
onSuccess = {
if (except?.excepted == ConsoleJvmPluginFuncCallbackStatus.FAILED) {
val msg = "Test point '${javaClass.name}' assets failed but onEnable() invoked successfully"
val msg =
"Test point '${javaClass.name}' assets failed but onEnable() invoked successfully"
cancel(msg)
logger.error(msg)
throw AssertionError(msg)
Expand Down Expand Up @@ -205,7 +206,9 @@ internal abstract class JvmPluginInternal(
.plus(parentCoroutineContext)
.plus(CoroutineName("Plugin ${(this as AbstractJvmPlugin).dataHolderName}"))
.plus(
SupervisorJob(parentCoroutineContext[Job] ?: JvmPluginLoader.coroutineContext[Job]!!)
SupervisorJob(
parentCoroutineContext[Job] ?: JvmPluginLoader.coroutineContext[Job]!!
)
)
.also {
if (!MiraiConsole.isActive) return@also
Expand Down Expand Up @@ -237,7 +240,10 @@ internal abstract class JvmPluginInternal(
// endregion
}

internal inline fun AtomicLong.updateWhen(condition: (Long) -> Boolean, update: (Long) -> Long): Boolean {
internal inline fun AtomicLong.updateWhen(
condition: (Long) -> Boolean,
update: (Long) -> Long
): Boolean {
while (true) {
val current = value
if (condition(current)) {
Expand All @@ -249,4 +255,5 @@ internal inline fun AtomicLong.updateWhen(condition: (Long) -> Boolean, update:
}
}

internal val Throwable.rootCauseOrSelf: Throwable get() = generateSequence(this) { it.cause }.lastOrNull() ?: this
internal val Throwable.rootCauseOrSelf: Throwable
get() = generateSequence(this) { it.cause }.lastOrNull() ?: this

0 comments on commit ee68f39

Please sign in to comment.