mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-23 22:00:10 +08:00
Throw NoSuchComponentException
with full details in CombinedComponentStorage.get
This commit is contained in:
parent
9933fab4c5
commit
e6119e6301
@ -53,7 +53,12 @@ private class CombinedComponentStorage(
|
||||
override val size: Int get() = main.size + fallback.size
|
||||
|
||||
override fun <T : Any> get(key: ComponentKey<T>): T {
|
||||
return main.getOrNull(key) ?: fallback.getOrNull(key) ?: main[key] // let `main` throw exception
|
||||
return main.getOrNull(key) ?: fallback.getOrNull(key) ?: throw NoSuchComponentException(key, this)
|
||||
.apply {
|
||||
//
|
||||
kotlin.runCatching { main[key] }.exceptionOrNull()?.let(::addSuppressed)
|
||||
kotlin.runCatching { fallback[key] }.exceptionOrNull()?.let(::addSuppressed)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : Any> getOrNull(key: ComponentKey<T>): T? {
|
||||
|
Loading…
Reference in New Issue
Block a user