You are an enterprise application developer. You create an application to provide an enterprise- wide barcode printing solution. You are developing a component that contains a method named InitializePrinter. The method will call a private function named IsPrinterLicensed to verify the license of the printer for the application. You need to ensure that the exceptions raised by the IsPrinterLicensed function bubble up to the application that calls the InitializePrinter method.
You
also need to ensure that the exceptions contain contextual information. Which code segment should you use?
A.
nResult = IsPrinterLicensed(printerName);InitPrinter(printerName);
B.
try
{
nRes ult = IsPrinterLic ensed(printerName);
InitPrinter(printerName);
}
catch (Exception ex)
{
throw ex;
}
C.
try
{
nResult = IsPrinterLicensed(printerName);
InitPrinter(printerName);
}
catch (Exception ex)
{
throw new Exception(“Exception thrown from InitializePrinter”);
}
D.
try
{
nResult = IsPrinterLicensed(printerName);
InitPrinter(printerName);
}
catch (Exception ex)
{
throw new Exception(“Exception thrown from InitializePrinter”, ex);
}