DRAG DROP
You are creating a method that saves information to a database.
You have a static class named LogHelper. LogHelper has a method named Log to log the
exception.
You need to use the LogHelper Log method to log the exception raised by the database
server. The solution must ensure that the exception can be caught by the calling method,
while preserving the original stack trace.
How should you write the catch block? (Develop the solution by selecting and ordering the
required code snippets. You may not need all of the code snippets.)
Answer: See the explanation.
Note:
Catch the database exception, log it, and then rethrow it.* SQLException
An exception that provides information on a database access error or other errors.
Solution
catch (SqlException ex)
{
LogHelper.Log(ex);
throw;
}
reason: using “throw” preserves the original stack trace.
Correct
PaulC is correct