exception_notification v4.0.0 の話です。
v4.0.0から通知処理をバックグラウンド実行する、以下のようなコードが書けるようになりました。
begin
some code...
rescue => e
ExceptionNotifier.notify_exception(e)
end
これは便利なのですが、1点認識しておかないといけないことがあります。
ExceptionNotifier では以下の3つの Exception についてはデフォルトで処理しないようにハードコードされています。
- ActiveRecord::RecordNotFound
- AbstractController::ActionNotFound
- ActionController::RoutingError
もしこれらを処理対象としたいのであれば、ここにあるように ignore_exceptions オプションを利用して、例えば下記のような定義をする必要があります。
Whatever::Application.config.middleware.use ExceptionNotification::Rack,
:ignore_exceptions => '',
:email => {
:email_prefix => "[Whatever] ",
:sender_address => %{"notifier" <notifier@example.com>},
:exception_recipients => %w{exceptions@example.com}
}