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

[Image] Throw exception if incorrect data type is passed in #164

Merged
merged 1 commit into from
Dec 7, 2020

Conversation

chrisbanes
Copy link
Contributor

GlideImage, CoilImage and PicassoImage currently all accept an Any param for data. There have been examples of developers passing in things like Drawables, ImageBitmaps, and others, which are not supported. To aid developers, we now throw an exception when any Drawable, ImageBitmap, ImageVector or Painter is passed in.

GlideImage, CoilImage and PicassoImage currently all accept
an `Any` param for data. There have been examples of developers
passing in things like Drawables, ImageBitmaps, and others, which
are not supported. To aid developers, we now throw an exception
when any Drawable, ImageBitmap, ImageVector or Painter is passed
in.
@chrisbanes chrisbanes changed the title Throw exception if incorrect data type is passed in [Image] Throw exception if incorrect data type is passed in Dec 7, 2020
Copy link
Collaborator

@nickbutcher nickbutcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LG but rather than throwing for incorrect usage, is accepting Any the right API? Would more restrictive types help prevent these errors?

@chrisbanes
Copy link
Contributor Author

chrisbanes commented Dec 7, 2020

I don't really want to maintain more overloads for each type which each library supports.

We could wrap the data param in a sealed class to enforce the type, but that adds friction for usage (and we'd need to maintain the whitelist for each library).

@chrisbanes chrisbanes merged commit 0d09c43 into main Dec 7, 2020
@chrisbanes chrisbanes deleted the cb/exception-data-param branch December 7, 2020 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants