Question: ActionController::Metal How to catch all exceptions to send notification email?

Question

ActionController::Metal How to catch all exceptions to send notification email?

Answers 1
Added at 2016-12-28 21:12
Tags
Question

I am using ActionController::Metal inherted controllers for for rails services, I want to catch all exceptions , So that I can notify myself through email

rescue_from Exception is not working

I have used above code in another app in application controller it is working good But not in this case

Which module should be included in to base controller in order to use it any help?

Code:

  rescue_from Exception do |exception|
    Rails.logger.warn "\n-EXCEPTION OCCURE IN APPLICATION-\n============\n-On\n-#{Time.now}\n======\nRequest-refer\n#{request.referer}\n=====\nrequest.xhr?\n#{request.xhr?}\n=======\nRequest environment\n#{request.env["HTTP_USER_AGENT"]}\n====\n-MESSAGE\n-#{exception.message}\n======\n-Url\n-#{request.url} \n============\n-Backtrace\n-#{exception.backtrace}"
  end
Answers
nr: #1 dodano: 2016-12-29 00:12

I'm not sure if this speaks to your exact problem, or whether you really need to create this yourself, but if you're open to additional dependencies I use the exception_notifier gem for this.

Source Show
◀ Wstecz