Various processing methods of Rails exception handling in # # #
1. Routes match ' *path ', via:: All, to: ' Controller#action '
2. APPLICATION.RB's Exception_app
"Ruby
# APPLICATION.RB
Config.exceptions_app = (env) {exceptioncontroller.action (: Show). Call (ENV)}
config.action_dispatch.rescue_responses["Actioncontroller::routingerror"] =: not_found
config.action_dispatch.rescue_responses["actioncontroller::badrequest"] =: bad_request
```
3. Exception_notification config/environments/
"Ruby
#异常邮件通知
Config.action_mailer.raise_delivery_errors = True
Config.action_mailer.delivery_method =: SMTP
Config.action_mailer.smtp_settings = {
: Address = "smtp.163.com",
:p ort = 25,
:d omain = "163.com",
: Authentication =: Login,
: user_name = "[email protected]",
:p assword = "1234567ZXCVBNM"
}
Config.middleware.use Exceptionnotifier,
: Email_prefix = "[FGCC program Exception]",
: sender_address =%{"Exception notice" <[email protected]>},
: Exception_recipients =%w{[email protected]}
```
4. Slack & Exception_notification
"Ruby
# Gemfile
# Slack API Package
Gem ' Slack-notifier '
# exception Monitoring
Gem ' exception_notification '
```
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Rails Exception Handling