Are the following code snippets essentially equivalent?
catch(Exception E) {
...
throw E; //Explicitly rethrow the exception
}
and
catch(Exception E) {
...
throw; //Implicitly rethrow the exception
}
Duplicate of this question.
Are the following code snippets essentially equivalent?
catch(Exception E) {
...
throw E; //Explicitly rethrow the exception
}
and
catch(Exception E) {
...
throw; //Implicitly rethrow the exception
}
Duplicate of this question.
NO.
catch(Exception E)
{
...
throw E; //Explicitly rethrow the exception
}
This one restarts the stack trace, while throw keeps the stack trace and adds to it.
IF you are going to rethrow the exception use throw.