#121281 - Mr Snowflake - Sun Mar 11, 2007 2:46 am
For the same project as in my previous topic I, obviously, need exception handling. But I don't know how to handle, cleanly, a specific situation: Say I have a function:
If I call this function from an other function, and I need to keep toBeCalled() looping through nameList even if an exception is encountered (in this case, I just want to display a message saying name is empty, but it's not critical, so I can continue). How should I do it?
- I could catch the exception in toBeCalled(), and then jump back in the for lus with goto. But this is really bad and with this foreach loop, I don't even think it is possible to pickup where I left. but then there's the problem that I do not know how to output the error and if to output the error when in toBeCalled().
- I could keep a Vector with all the exceptions generated in toBeCalled(), but for some reason I don't really like this and I prefer having the exceptions outputted immediately.
In my project I use the foreach loop. And it is a Java project.
And to improve my English writing: How is my English?? :)
_________________
http://www.mrsnowflake.be
Code: |
function toBeCalled() throws SomeException{ for(String name : nameList) if(name.compareTo("") == 0) throw new SomeException(); } |
If I call this function from an other function, and I need to keep toBeCalled() looping through nameList even if an exception is encountered (in this case, I just want to display a message saying name is empty, but it's not critical, so I can continue). How should I do it?
- I could catch the exception in toBeCalled(), and then jump back in the for lus with goto. But this is really bad and with this foreach loop, I don't even think it is possible to pickup where I left. but then there's the problem that I do not know how to output the error and if to output the error when in toBeCalled().
- I could keep a Vector with all the exceptions generated in toBeCalled(), but for some reason I don't really like this and I prefer having the exceptions outputted immediately.
In my project I use the foreach loop. And it is a Java project.
And to improve my English writing: How is my English?? :)
_________________
http://www.mrsnowflake.be