title: Best practices when reporting exception messages to the user
body: <p>In my ASP.NET MVC application, I do not want to report all exception messages to the user.  But there are certain types of exceptions that I'd like to report to the user, so I created an action filter to decide if it's this particular type of exception, and if so then display the exception's message, otherwise display a generic message. So I created a custom exception called ClientException.</p>
  
  <p>My filter looks something like this:</p>
  
  <pre><code>    if (filterContext.Exception is ClientException)
           message = filterContext.Exception.Message.Replace("\r", " ").Replace("\n", " ");
     else
          message = "An error occured while attemting to perform the last action.  Sorry for the inconvenience.";
  
      filterContext.HttpContext.Response.Status = "500 " + message;
  </code></pre>
  
  <p>I read this <a href="http://blogs.msdn.com/b/kcwalina/archive/2007/01/30/exceptionhierarchies.aspx" rel="noreferrer">http://blogs.msdn.com/b/kcwalina/archive/2007/01/30/exceptionhierarchies.aspx</a> where the author recommends using existing .NET exception types to report usage errors.  However, by introducing my custom exception, I just have to do a single check in my filter.  Is my approach okay?</p>