title: How to Return Errors from an ASMX Web Service?
body: <p>My web service method returns a collection object, this will serialize nicely, thanks to the way C# web services work!</p>
  
  <p>But if my code throws an uncaught exception, I want to instead return a custom error object.</p>
  
  <p>Is this possible using C# ASP.NET v2?</p>
  
  <p>For example,</p>
  
  <p>Normal Operation should return:</p>
  
  <pre><code>&lt;Books&gt;
      &lt;book&gt;Sample&lt;/book&gt;
      &lt;book&gt;Sample&lt;/book&gt;
  &lt;/Books&gt;
  </code></pre>
  
  <p>But on error I want</p>
  
  <pre><code>  &lt;error&gt;
        &lt;errorMessage&gt;&lt;/errorMessage&gt;
    &lt;/error&gt;
  </code></pre>