mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Add assertionError
This commit is contained in:
parent
6f3e59856e
commit
fb82d8236d
@ -7,12 +7,14 @@
|
|||||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:JvmName("CommonUtils")
|
@file:JvmName("CommonUtils") // maintain binary compatibility
|
||||||
|
|
||||||
package net.mamoe.mirai.console.internal.util
|
package net.mamoe.mirai.console.internal.util
|
||||||
|
|
||||||
import io.github.karlatemp.caller.StackFrame
|
import io.github.karlatemp.caller.StackFrame
|
||||||
import net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl
|
import net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl
|
||||||
|
import kotlin.contracts.InvocationKind
|
||||||
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
internal inline fun <reified E : Throwable, R> runIgnoreException(block: () -> R): R? {
|
internal inline fun <reified E : Throwable, R> runIgnoreException(block: () -> R): R? {
|
||||||
try {
|
try {
|
||||||
@ -38,3 +40,9 @@ internal fun StackFrame.findLoader(): ClassLoader? {
|
|||||||
BuiltInJvmPluginLoaderImpl.classLoaders.firstOrNull { it.findClass(className, true) != null }
|
BuiltInJvmPluginLoaderImpl.classLoaders.firstOrNull { it.findClass(className, true) != null }
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PublishedApi
|
||||||
|
internal inline fun assertionError(message: () -> String): Nothing {
|
||||||
|
contract { callsInPlace(message, InvocationKind.EXACTLY_ONCE) }
|
||||||
|
throw AssertionError(message())
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user