smartinez87/exception_notification — Issue #61: :ignore_if option to accept request/env information
Author: holli
Created: 2012-02-14 16:15:34+00:00
State: open

The ignore_if options is a good start, but it could give env as a parameter

https://github.com/smartinez87/exception_notification/blob/master/lib/exception_notifier.rb#L30

```
@options[:ignore_if] ||= lambda { |env, e| false }

unless ignored_exception(options[:ignore_exceptions], exception) ||
from_crawler(options[:ignore_crawlers], env['HTTP_USER_AGENT']) ||

options[:ignore_if].call(env, exception) # < THIS LINE ALSO

Notifier.exception_notification(env, exception).deliver
env['exception_notifier.delivered'] = true
end
```

For us the mailing probability game. I would like to have custom rules like "If no session cookie in request and if user_agent not recognized". This so that we receive exception notifies in most cases but not with new unrecognized bots etc.

--------

In addition to this the ignore_if could be wrapped so that errors inside lambda would not affect. I'm not sure if this should be implemented or left to user. I'm just afraid that when lambda crashes you will lose the exception info and get no email.

```
ignored_if(options[:ignore_if].call(env, exception))

# wrapper so that if users lambda is errorous it will return true
def ignored_if(lamb, env, exception)
return lamb.call(env, exception)
rescue Exception => e
true
end

```