Catch an unhandled exception in WCF

Is there an event or method in WCF that catches unhandled exceptions, or do I need to put try / catch in any way?

+5
source share
2 answers

Yes, create a class that implements the interface IErrorHandler:

Allows the developer to manage the error message returned to the caller, and possibly perform selective error handling, such as logging.

+7
source

You must do TRY / Catch indoor and outdoor units.

So the first method starts with Try

, - , catch , , .

logging catch, , , catch, - ", , WCF.Blah . "

, .

public class Service1 : IService1
    {
    public string GetData(int value)
    {
        try
        { 
            return somemethod(value);
        }
        catch(Exception ex)
        {
            LoggingHelper.Log(ex);
            return "Please Except our Appogies the WCF.Blah service has failed. Please review the server logs for complete details";
        }
    }
0

All Articles