coil-kt / coil

Image loading for Android and Compose Multiplatform.
https://coil-kt.github.io/coil/
Apache License 2.0
10.83k stars 664 forks source link

Pass throwable to logger when logging errors #2609

Closed sigmabeta closed 1 week ago

sigmabeta commented 3 weeks ago

When an image fails to load, a registered Logger should receive the throwable describing what happened. Unfortunately, RealImageLoader's implementation does not do this, so as far as I can tell there is no reason a logger would ever be called with a non-null throwable argument.

This is a quick and dirty proof of concept of what a fix might look like. I suspect the string was previously generaetd in a lambda to avoid generating the string in cases where it won't actually be used (a performance benefit), and this PR as currently implemented loses that benefit. I would also add an extension function that both lambdifies the string and doesn't lose the throwable before merging this.

colinrtwhite commented 1 week ago

Merged in your fix here. Thanks for suggesting it!