Which code segment should you use?

You are developing an application that uses structured exception handling. The application includes
a class named Logger. The Logger class implements a method named Log by using the following code
segment:
public static void Log(Exception ex) { }
You have the following requirements:
Log all exceptions by using the Log() method of the Logger class.
Rethrow the original exception, including the entire exception stack.
You need to meet the requirements. Which code segment should you use?

You are developing an application that uses structured exception handling. The application includes
a class named Logger. The Logger class implements a method named Log by using the following code
segment:
public static void Log(Exception ex) { }
You have the following requirements:
Log all exceptions by using the Log() method of the Logger class.
Rethrow the original exception, including the entire exception stack.
You need to meet the requirements. Which code segment should you use?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 5

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


Serge

Serge

Rethrow the original exception, including the entire exception stack.

Answer is B:
throw ex; – will throw entire exception stack.

throw; – also will throw the exception but will preserve the stack.

hedz

hedz

its D you are contradicting yourself.