title: How to return standard message on exception/fault in WCF
body: <p>In our application all data contract have one parent - <code>OperationResponse</code> and this <code>OperationResponse</code> contains enum (enum type <code>OperationState</code> in property <code>Result</code>) which represents calling result (<em>Ok</em>, <em>InvalidParams</em>, <em>Error</em>).</p>
  
  <p>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?</p>
  
  <p><strong>Edit:</strong> 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...</p>
  
  <pre><code>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?
  }
  </code></pre>
  
  <p><strong>Edit2:</strong> It seems like it's unbreakable problem without solution... I only found same questions without solution like <a href="http://forums.asp.net/t/1865838.aspx?How%20can%20I%20handle%20the%20exceptions%20without%20returning%20a%20Fault%20message%20in%20WCF%20" rel="nofollow">this thread</a>... :(</p>