Try to catch a question

I am doing this in C #. These are code layers.

VIEW β†’ VIEWHANDLER β†’ BusinessLayer β†’ WCF SERVICE

The view invokes the ViewHandler, which invokes the business layer that invokes the service. The service throws a failure exception. All exceptions are handled in the View handler. The business layer re-throws the failure exception that it receives from the service that must be processed in VIEWHANDLER. What is the best way to rebuild it in BusinessLayer?

catch(FaultException f) { throw f; } 

or

 catch(FaultException f) { throw; } 

Does "throw f" discard the call stack information contained in the thrown exception? and throws it as-is?

+4
source share
2 answers

Yes, throw f; will reset the stack.

throw; will not be.

In any case, if that’s all you do in the catch , you better not use the try-catch at all, as that is pointless.

+6
source

Yes, you should use throw , not throw f . If you do nothing in the catch statement, you can leave catch .

+3
source

All Articles