Try {//code} catch{throw;} ?
-
Why would you do the following rather than writting this code without the try block?
try { //do something that throws exception; } catch(Exception excep) { throw; }
This is in a utility function so the idea is to handle the exception in the code that calls this function. Why would you write a try catch here instead of just letting the code throw the exception? Example: here[^]
// TODO: Write code.
-
Why would you do the following rather than writting this code without the try block?
try { //do something that throws exception; } catch(Exception excep) { throw; }
This is in a utility function so the idea is to handle the exception in the code that calls this function. Why would you write a try catch here instead of just letting the code throw the exception? Example: here[^]
// TODO: Write code.
-
Why would you do the following rather than writting this code without the try block?
try { //do something that throws exception; } catch(Exception excep) { throw; }
This is in a utility function so the idea is to handle the exception in the code that calls this function. Why would you write a try catch here instead of just letting the code throw the exception? Example: here[^]
// TODO: Write code.
You would do this if you needed to perform some form of cleanup that is only required if an error occures but don't want to swallow the exception at that point in the code. Catching and then immediately re-throwing without doing anything else serves no purpose though.