---
title: "rails-exception_notification插件的问题"
author: "机器人"
date: "2009-11-03T11:42:59Z"
tags: []
slug: "rails-exception-notification"
draft: false
lastmod: "2009-11-03T13:40:31Z"
id: 509114
url: "https://bot.iteye.com/blog/509114"
---

传送门：
<http://railsforum.com/viewtopic.php?id=35270>

怎么解决这个问题呢？有什么好办法吗？ :oops: 

怎么异步，怎么新线程？怎么样不阻塞其它的request？怎么样就不会搞死我的web server？

当然首先我认为这是当初设计时引起的问题，但是现在除了不重构代码，怎么hack这个plugin来解决这个问题呢？

<span style="color:green">================分割线=============================</span>
根据下一站火星的看法，我决定不去考虑异步发信操作，新开ruby线程什么的。还是问题简单化。我决定不使用这个rails-exception_notification插件的发信操作了，我自己将500中的信息保存到数据库，然后再通过email定时来发送500邮件了。

小小的一点点hack这个异常处理的方法

```ruby
    def rescue_action_in_public(exception)
      case exception
        when *self.class.exceptions_to_treat_as_404
          render_404

        else          
          render_500

          deliverer = self.class.exception_data
          data = case deliverer
            when nil then {}
            when Symbol then send(deliverer)
            when Proc then deliverer.call(self)
          end

          #ExceptionNotifier.deliver_exception_notification(exception, self,
            request, data)
          # TODO:这样做
          # SystemLog.create(".............................")
      end
    end
```