понедельник, 22 сентября 2008 г.

Exceptions and nulls

Argh, I'm irritated at Android's inconsistency when dealing with errors.
Consider loading a drawable (bitmap).
If you load bitmap by yourself via BitmapFactory.decodeFile, you will get null in case of error.
If you load bitmap drawable via Resources.getDrawable, and there is a problem, you will get NotFoundException with nested IOException.
You can also load via Drawable.createFromPath, and you will again get Drawable or null.

I will add 'Throw' versions of some functions (decodeFileThrow) that will throw exceptions.

Комментариев нет: