You do not need to try, catch, and rethrow exceptions unless you have some particular reason for catching them in the first place. Otherwise, they'll automatically get bubbled up from the lower level functions that throw them to the highest level function in your code. Essentially, you can think of them as getting "rethrown" all the way up, even though this isn't technically what is happening.
You do not need to try, catch, and rethrow exceptions unless you have some particular reason for catching them in the first place. Otherwise, they'll automatically get bubbled up from the lower level functions that throw them to the highest level function in your code. Essentially, you can think of them as getting "rethrown" all the way up, even though this isn't technically what is happening.In fact, most of the time that you see a try/catch block written, it's incorrect.
You should not catch exceptions unless you can actually handle them. It's utterly pointless (and in fact considered to be bad practice) to catch exceptions just to rethrow them.Do not wrap all of your code within try blocks. Note that by "handle them", I mean that your code in the catch block will take some specific action based on the particular exception that was thrown that attempts to correct the exceptional condition.
For example, for a FileNotFoundException, you might inform the user that the file could not be found and ask them to choose another one. See my answer here for more detail and a thorough discussion of "exception handling best practices".
You don't need to wrap everything in try blocks. You should only try when you want to catch something, and you should only catch something in the following cases: You're ready to handle the exception (do whatever needs to be done and don't let it propagate up the stack), You want to do something with the exception (e.g. Log it) before rethrowing it (by using the parameterless form of throw), You want to add details to the exception by wrapping it in another exception of your own (see Allon Guralnek's excellent comment below).
2 +1: concise and accurate. I'd add one more reason that isn't exactly 'rethrowing' - wrap an exception inside a different exception (but always keep the original exception in the InnerException, otherwise you lose information about the original exception which could aid debugging). Wrapping could give additional context that rethrowing cannot, e.g."Failed to save a new order for Customer 843, see InnerException for details.
". – Allon Guralnek Jul 9 at 9:53.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.