How should you write the catch block?

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.)
Select and Place:

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.)
Select and Place:

Answer:

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.



Leave a Reply 3

Your email address will not be published. Required fields are marked *


erm

erm

2,8,4,5

It should be used “throw” rather than “throw ex” to ensure that the original stack trace is preserved

Jah

Jah

just use throw if you want to keep the stack