In our application all data contract have one parent - OperationResponse
and this OperationResponse
contains enum (enum type OperationState
in property Result
) which represents calling result (Ok, InvalidParams, Error).
How can I overwrite WCF behavior after exception - not return Fault state, but return classic message, OperationResponse in my case, but with property Result = OperationState.Error?
Edit: I think, I'm on right way, I need to implement IErrorHandler, but now I'm lost, because I don't know how to set error message into outgoing fault message...
public bool HandleError(Exception error)
{
// log error
return true; // we catch error and provide our custom message.
}
public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
{
// create result message
var message = new OperationResponse
{
Result = OperationState.Error
};
// ok how to return message into ref fault?
}
Edit2: It seems like it's unbreakable problem without solution... I only found same questions without solution like this thread... :(