Skip to content

Commit

Permalink
catch only NoDefinitionFoundException
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgiuliani committed Sep 9, 2024
1 parent 932afb3 commit d6cccad
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.koin.android.ext.koin
import android.app.Application
import android.content.Context
import org.koin.android.error.MissingAndroidContextException
import org.koin.core.error.NoDefinitionFoundException
import org.koin.core.scope.Scope

const val ERROR_MSG = "Please use androidContext() function in your KoinApplication configuration."
Expand All @@ -29,7 +30,7 @@ const val ERROR_MSG = "Please use androidContext() function in your KoinApplicat
*/
fun Scope.androidContext(): Context = try {
get()
} catch (e: Exception) {
} catch (e: NoDefinitionFoundException) {
throw MissingAndroidContextException("Can't resolve Context instance. $ERROR_MSG")
}

Expand All @@ -40,6 +41,6 @@ fun Scope.androidContext(): Context = try {
*/
fun Scope.androidApplication(): Application = try {
get()
} catch (e: Exception) {
} catch (e: NoDefinitionFoundException) {
throw MissingAndroidContextException("Can't resolve Application instance. $ERROR_MSG")
}

0 comments on commit d6cccad

Please sign in to comment.