Exceptions interview questions
try/catch/finally, filters, rethrowing, best practices.
3 questions with answers and explanations · 2 flashcards
Key ideas
finallyalways runs when control leaves thetry(return, exception or normal exit).- Use
throw;to rethrow and keep the original stack trace;throw ex;resets it. - Exception filters (
catch (X e) when (...)) run *before* the stack unwinds. - Catch what you can handle, as specifically as possible; don't use exceptions for normal control flow.