Can I move my exception code to a handling function. So I don't have to repeat same code
<p>I currently handle my exceptions like this:</p>

<pre><code>try {

        }
        catch (ServiceException ex) {
            ModelState.Merge(ex.Errors);
        }
        catch (Exception e) {
            Trace.Write(e);
            ModelState.AddModelError("", "Database access error: " + e.Message);
        }
</code></pre>

<p>This works but it's the same code I repeat many times. What I am looking for is some suggestion on how I could move this into an external function. I don't necessarily need to move the try block there but at least the other code. </p>

<p>Maybe a function that was passed the Exception and the ModelState (as a reference). Can anyone suggest a clean way that I could code up this function. I'm asking here because almost always someone seems to come up with a solution that I could never have thought of. Thanks Samantha.</p>
