Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetOrNull covers possibly important exceptions #913

Closed
hrach opened this issue Oct 7, 2020 · 5 comments
Closed

GetOrNull covers possibly important exceptions #913

hrach opened this issue Oct 7, 2020 · 5 comments
Milestone

Comments

@hrach
Copy link

hrach commented Oct 7, 2020

Describe the bug

This already happended to us twice. This time we had to release production build with more debugging to realize what is actually happening, because the current stack trace is not sufficient for us.

The root cause is implementation of getOrNull and findInOtherScope where getOrNull silences all possible exceptions.

To Reproduce

Steps to reproduce the behavior:

  1. Have a scope and MAIN dependency in it.
  2. The MAIN dependency requires ANOTHER dependency in root scope.
  3. Constructor of the ANOTHER depency throws.

Actual behavior

Caused by org.koin.core.error.NoBeanDefFoundException
No definition found for class:'xxx.AnotherDependency'. Check your definitions!

Expected behavior

Caused by xxx.CustomException

How to fix

Catch only NoBeanDefFoundException exceptions in getOrNull.

This may introduce BC break since somebody may rely on this behaviour. So alternatively also findInOtherScope should be reworked not to utilize getOrNull.

Koin project used and used version (please complete the following information):

implementation "org.koin:koin-core:v2.1.5"
implementation "org.koin:koin-android:v2.1.5"
implementation "org.koin:koin-androidx-scope:v2.1.5"
implementation "org.koin:koin-androidx-viewmodel:v2.1.5"
implementation "org.koin:koin-androidx-fragment:v2.1.5"
implementation "org.koin:koin-androidx-ext:v2.1.5"
@arnaudgiuliani
Copy link
Member

Thanks, fix added to 2.2.0 branch

@arnaudgiuliani arnaudgiuliani added this to the 2.2.0 milestone Oct 8, 2020
@hrach
Copy link
Author

hrach commented Oct 9, 2020

Thanks you! Could you please point me to the fix? I can't find it.

@hrach
Copy link
Author

hrach commented Oct 13, 2020

@arnaudgiuliani Could you please point me to the fix? Thanks :)

@hrach
Copy link
Author

hrach commented Oct 13, 2020

❤️ 👍 thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants