Inside a catch block, what is the difference between throw; and throw ex;?
Correct answer B. throw; keeps the original stack trace, while throw ex; resets it to the current point
A bare throw; rethrows the exception being handled and preserves its original stack trace, so logs still show where the error really started. throw ex; throws the same object as if it were new, replacing the stack trace with the location of the catch block and hiding the true origin. Prefer throw;, or wrap the exception in a new one with it as InnerException.
Answer checked How we write and check questions
Discussion