• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple exceptions  RSS feed

 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a process which reads files from a location over the server writes it to my local PC and FTPs all the files at once to a different location

The process runs smooth and goes through successfully in a normal scenario,However in certain cases...It give me exceptions like being unable to read,Unable to open stream, and certain other exceptions

Whenever one of these exceptions arise the whole process fails.......But i want the process to go on and read other files and do its thing......!!!

How can I do this any suggestions please
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Easy answer: catch the exception and log the error, then go on with your processing.

However, if you're seeing the errors come in a spate, it might be that you're running out of resources, maybe because you're not closing files properly. In that case, ending the program is the only way you recover those resources in order to continue. In general, you want to open resources in a try block, and close them in a finally block. Be very careful that there is no path through the code that prevents an opened resource from being closed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!