frankiesardo / icepick

Android Instance State made easy
Eclipse Public License 1.0
3.75k stars 208 forks source link

More declarative exceptions. #33

Open Trikke opened 10 years ago

Trikke commented 10 years ago

Would it be possible to have a more descriptive exception on null objects or any exception detailing one of the objects being injected?

Currently i have an Activity with a large number of @Icicles, and it's hard to find out which one is wrong once users report this error through Google Play.

java.lang.NullPointerException
at com.Activity$$Icicle.saveInstanceState(Activity$$Icicle.java:27)
at com.Activity$$Icicle.saveInstanceState(Activity$$Icicle.java:6)
at icepick.Action$1.invoke(Action.java:6)
at icepick.ObjectInjector.inject(ObjectInjector.java:16)
at icepick.Icepick.saveInstanceState(Icepick.java:17)
at 
frankiesardo commented 10 years ago

Could this be related to #31?

Trikke commented 10 years ago

In a sense, yes. It would be nice if we can state what @icicles can be nullable. But I still think it's a good idea to be as descriptive as possible when throwing exceptions in a library which injects code. Butterknife is a good example for this, if a View cannot be found, it throws an error stating the resource ID and field name. It would be nice if Icepick would let me know what @icicle it has troubles with.

frankiesardo commented 10 years ago

I suppose every statement could be wrapped in a try/catch block that will provide all the necessary info if it fails. Sounds useful.