views:

120

answers:

1

Is there a way to filter exceptions in elma using the exception message?

Examples:
"System.Web.HttpException: Request timed out." I don't want to filter out all HttpException, but only the timed-out requests.
"System.Web.HttpException: Maximum request length exceeded."

What I don't want to do is write own code for that. So is it possible to do this with the buildin-web.config configuration?

Thank you!

+1  A: 

Yes you can. Just use a regular expression to interigate the message. See the example below for details on how to compare the exception message.

<errorFilter>
  <test>
    <!-- http://groups.google.com/group/elmah/t/cbe82cee76cc6321 -->
    <and>
      <is-type binding='Exception'
               type='System.Web.HttpException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' />
      <regex binding='Exception.Message'
             pattern='invalid\s+viewstate'
             caseSensitive='false' />
      <regex binding='Context.Request.UserAgent'
             pattern='Trident/4(\.[0-9])*'
             caseSensitive='false' />
    </and>
  </test>
</errorFilter>
Drew Freyling