On Sat, 09 Aug 2008 12:48:56 -0700, Tom P. <pa***********@gmail.comwrote:
[...] So far I choose to handle both of these
instances the same way, by simply ignoring the string in the renaming
process. I'm not sure yet that I want to ignore EVERY exception, but
so far these two do, in fact, have the same resolution.
But that resolution has little to do with their actual types. You could
just as easily catch the type "Exception". If later you have some other
exception that you want to provide more specific handling for, then you
can include a catch clause specific to that exception (putting it before
the one that catches "Exception", of course).
It might be that in the future, you want to provide the user with better
feedback about why their input is wrong. The user certainly would have a
much better idea of how to fix their input that's not working if they know
whether it's a problem with the format of that input (i.e. entering a
letter when a number was expected) or the meaning of that input (i.e.
entering a number that is itself invalid). And of course, it's also much
easier to fix a problem if the user is actually informed that there's a
problem, but that's a separate issue. :)
But in the meantime, if you're just ignoring the errors, you don't need to
catch a specific exception. Add a specific exception clause if and when
you have something you want to do that actually requires knowing what the
type of the exception is.
Pete