getOrElseThrow

abstract fun <T, X : Throwable?> getOrElseThrow(type: Class<T>, exceptionSupplier: Supplier<out X>): T

Return an instance from the context if the type has been registered. The instance will be created if it hasn't been accessed previously.

Return

the instance managed by the context

Parameters

<T>

the instance type

<X>

the exception to throw if the type is not registered

type

the instance type

exceptionSupplier

the supplier which will return the exception to be thrown

Throws

if the type has not been registered

if the type has not been registered