On Jan 18, 4:02 am, Zsolt Vasvari <zvasv...@gmail.com> wrote:
> > Have an app that in various activities handles any number of types of
> > Exceptions, such as IOException, FileNotFoundException, SAXException,
> > etc. In some cases, I want an exception to terminate the called
> > Activity and alert the user of an error, in others, I can handle the
> > Exception more gracefully,
>
> By definition, you cannot handle exceptions gracefully.  If you can,
> you have a design problem as exceptions should never be used as a
> replacement for normal flow control.  For example, if you use
> FileNotFoundException to indicate that you need to create the file,
> you should instead be checking the file's existence directly using
> file.exists().  FileNotFoundException is all but useless.
>
> The only exception (not pun intended) is the likes of
> NumberFormatException which comes up during parsing.  But I'd agrue
> that's an artifact of poor API design, where returning a special value
> would have been sufficient to indicate a problem.

Gracefully meaning alert user if appropriate and Exception state
doesn't cause fundamental instability.  For instance, if a user
launches a new activity to create a new contact from a contact
management app, and that fails throwing some exception, they should
probably still be able to use app to view contacts rather than
crashing out all the way to the force close screen as viewing is still
an important function.

-- 
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

Reply via email to