I guess there is an elegant way to do this, but I don't know what it is. In the application I'm working on, I have many ContentResults that return xml. Each action that returns xml goes through the same try / catch block, and I repeat over and over - here is an example of what I'm talking about:
public ContentResult SomeAction()
{
try
{
}
catch(Exception ex)
{
HandleErrorMethod(ex);
}
return this.Content(someObject.ToXmlString(), contentReturnType);
}
This happens 3-4 times in the controller, so I believe that I can either draw it using an attribute, or run some method in global.asax or something like this, so as not to repeat myself again and again - without saying already about code changes in the future. I really don't know where to look (I suppose that's why I ask); Thank!