Hi. Basically I need some general advice about how to handle Exceptions in my Java program.
I'm a student and as a favour for a company I'm writing a program which is used to enter data to a database and transfer data back and forth between the database and some excel files (for printing graphs and such).
One specific question I have is, I have inner SwingWorker classes that handle the data transfers between the database and the excel files. Should I handle Exceptions within those classes or send them to the outer class for processing? If the latter, how can I do that with a SwingWorker class since I just call the execute method and this runs the doInBackground method, which as I understand can not throw exceptions?
The other, and main, question is how should I handle Exceptions in general? I do propagate them up but the issue is, lets say I have a method with couple of hundred lines. Should I have the whole code in a single try block and catch exceptions at the end? Or should I catch them more often so that I can pinpoint errors? Also what about RuntimeExceptions?
The issue is that the company is abroad. Once deployed I won't be around. I need to be able to fix the code here and send it to them, if that's even possible. And I don't want the program to crash under any circumstances, at least not without displaying a message before hand so right now I'm catching every throwable, just to display a message before closing and writing it to a log file.
I'm open to any suggestions...