coil
coil copied to clipboard
Conflicting error extension function can lead to Unexpected Runtime Exceptions
Is your feature request related to a problem? Please describe.
The name of the extension function error for the ImageRequest.Builder class is confusing. I'm using Coil in a view-based Android project. I was using the ImageView.load function inside of a fragment and would use error(@DrawableRes drawableResId: Int). But since it's an extension function, it requires importing. When I was writing code, the IDEA automatically imported the error(message: Any) function from Kotlin stdlib, which throws IllegalStateException and causes a runtime exception.
Describe the solution you'd like
Could the error function be renamed to onError? Or the library should include a lint check that warns the user when there is an error(message: Any) function (from stdlib) usage in the context of ImageRequest.Builder class.
Yep this isn't ideal. Fortunately it only occurs with an implicit ImageRequest.Builder receiver which is only used with ImageView.load - not Compose.
I don't think we can rename error as it's heavily used and deprecating it will create a lot of warnings for users downstream. I think our best bet is to add a Lint check as you mentioned.