Minor, improve exception when getting missing component from container
This commit is contained in:
@@ -33,8 +33,10 @@ inline fun <reified T : Any> ComponentProvider.get(): T {
|
|||||||
return getService(T::class.java)
|
return getService(T::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST") fun <T : Any> ComponentProvider.getService(request: Class<T>): T {
|
@Suppress("UNCHECKED_CAST")
|
||||||
return resolve(request)!!.getValue() as T
|
fun <T : Any> ComponentProvider.getService(request: Class<T>): T {
|
||||||
|
val valueDescriptor = resolve(request) ?: throw IllegalArgumentException("Unresolved service: $request")
|
||||||
|
return valueDescriptor.getValue() as T
|
||||||
}
|
}
|
||||||
|
|
||||||
fun StorageComponentContainer.useInstance(instance: Any) {
|
fun StorageComponentContainer.useInstance(instance: Any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user