On Jul 28, 6:40 pm, Zsolt Vasvari <zvasv...@gmail.com> wrote: > - Most of my checked exceptions were repackaged SQLExceptions, which > are unchecked. And it's fine to be unchecked, because if I get a SQL > error, I cannot do anything about it other than roll back my > transaction and stop the app.
I'm curious what you mean by "stop the app"? What are you doing to recover, if anything? > - Another set of my checked exceptions were repackaged > JSONExceptions. Since all my JSON is created and consumed by me, if > there is a JSONException, it's a hard error and no use dealing with > it. It's not like I am dealing with RESTful web services providing me > with invalid JSON. Actually, this is a pretty good specific case to talk about. Are you loading JSON from or saving it to a file? I'm curious what would happen in the case that a write of a file in mid-stream failed. Would you end up with a partial JSON object (that would generate a JSONException on the subsequent read)? Or did you catch the IOException, remove the file, and notify the user? Also, would that partially generated file have put your app into a permanently bad state if the user hadn't uninstalled and reinstalled or wiped their sdcard? To dive in further, if this was a simple transient data cache, I wouldn't have any trouble catching relevant exceptions, failing the whole thing, and ignoring the error. On the other hand, if this was an explicit "save" mechanism, I would seriously consider catching any errors, rolling back partial actions, and notifying the user. All meaning is context sensitive. :-) > - Then I had some IOException I repackged. I am still doing this as > there is a remote possibility that an IOException is something the end > user can fix, like if they unmount their SD card. > > So basically, 95% of my checked excpetion handling was for stuff the > end user (or I) cannot recover from anyhow. My code is now hugely > simplified and not littered with try/catch/finally blocks. I'm curious to know what was in the 95% that you got rid of and what you did to deal with what were previously checked exceptions? Doug -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en