Closed yogurtearl closed 2 months ago
If the get() for a context throws an exception, the cause is discarded. (same applies for Scope.androidApplication())
get()
Scope.androidApplication()
The e here is discarded.
e
See this code: https://github.com/InsertKoinIO/koin/blob/5fab1ca74add39339e281aaa822c618a2da5baa3/projects/android/koin-android/src/main/java/org/koin/android/ext/koin/ModuleExt.kt#L30-L34
Instead it should be something like this:
class MissingAndroidContextException(message: String, cause: kotlin.Throwable?) : kotlin.Exception(message, cause) fun Scope.androidContext(): Context = try { get() } catch (e: Exception) { throw MissingAndroidContextException("Can't resolve Context instance. $ERROR_MSG", e) }
Thanks
If the
get()
for a context throws an exception, the cause is discarded. (same applies forScope.androidApplication()
)The
e
here is discarded.See this code: https://github.com/InsertKoinIO/koin/blob/5fab1ca74add39339e281aaa822c618a2da5baa3/projects/android/koin-android/src/main/java/org/koin/android/ext/koin/ModuleExt.kt#L30-L34
Instead it should be something like this: