lib/flail/exception.rb in flail-0.1.1 vs lib/flail/exception.rb in flail-0.1.2

- old
+ new

@@ -1,10 +1,18 @@ require 'socket' require 'json' class Flail class Exception + def self.notify(exception, request_data = {}) + env = {'flail.request' => {'user_agent' => 'internal'}} + + fe = Flail::Exception.new(env, exception) + fe.request_data = fe.request_data.merge(request_data) + fe.handle! + end + def initialize(env, exception, local = false) @exception = exception @env = env end @@ -30,10 +38,14 @@ :user => {}, } end end + def request_data=(value) + @request_data = value + end + def clean_unserializable_data(data, stack = []) return "[possible infinite recursion halted]" if stack.any? {|item| item == data.object_id} if data.respond_to?(:to_hash) data.to_hash.inject({}) do |result, (key, value)| @@ -108,10 +120,10 @@ end def ignore? # Ignore requests with user agent string matching # this regxp as they are surely made by bots - user_agents = request.respond_to?(:user_agent) ? request.user_agent : @env['HTTP_USER_AGENT'] + user_agents = request.respond_to?(:user_agent) ? request.user_agent : @env['HTTP_USER_AGENT'].to_s if user_agents =~ /\b(Baidu|Gigabot|Googlebot|libwww-perl|lwp-trivial|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg|Yandex|Jyxobot|Huaweisymantecspider|ApptusBot)\b/i return true end false