Skip to content

Commit

Permalink
Using ActionController::Rescue#rescue_action_without_handler instead …
Browse files Browse the repository at this point in the history
…of rescue_action, being more strict about when it gets included
  • Loading branch information
winton committed Dec 4, 2009
1 parent a7cee46 commit 4885eb8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
11 changes: 6 additions & 5 deletions lib/rack/lilypad.rb
Expand Up @@ -34,6 +34,10 @@ class <<self
def notify(e) def notify(e)
@@hoptoad.post(e) @@hoptoad.post(e)
end end

def production?
%w(staging production).include?(ENV['RACK_ENV'])
end
end end


class Hoptoad class Hoptoad
Expand Down Expand Up @@ -65,7 +69,7 @@ def log(*msg)
end end


def post(exception, env=nil) def post(exception, env=nil)
return unless production? return unless Lilypad.production?
uri = URI.parse("http://hoptoadapp.com:80/notifier_api/v2/notices") uri = URI.parse("http://hoptoadapp.com:80/notifier_api/v2/notices")
Net::HTTP.start(uri.host, uri.port) do |http| Net::HTTP.start(uri.host, uri.port) do |http|
headers = { headers = {
Expand All @@ -88,10 +92,6 @@ def post(exception, env=nil)
end end
end end


def production?
%w(staging production).include?(ENV['RACK_ENV'])
end

def xml(exception, env) def xml(exception, env)
environment = filter(ENV.to_hash.merge(env || {})) environment = filter(ENV.to_hash.merge(env || {}))
if env if env
Expand Down Expand Up @@ -148,6 +148,7 @@ def xml(exception, env)
end end


class <<self class <<self

def last_request def last_request
@@last_request @@last_request
end end
Expand Down
18 changes: 11 additions & 7 deletions lib/rack/lilypad/rails.rb
Expand Up @@ -6,15 +6,19 @@ module Rails


def self.included(base) def self.included(base)
ENV['RACK_ENV'] = ENV['RAILS_ENV'] ENV['RACK_ENV'] = ENV['RAILS_ENV']
base.send(:include, LilypadMethods) if Lilypad.production?
end end


private module LilypadMethods


def rescue_action(exception) private
super
request.env['rack.lilypad.component'] = params[:controller] def rescue_action_without_handler(exception)
request.env['rack.lilypad.action'] = params[:action] super
raise exception request.env['rack.lilypad.component'] = params[:controller]
request.env['rack.lilypad.action'] = params[:action]
raise exception
end
end end
end end
end end
Expand Down

0 comments on commit 4885eb8

Please sign in to comment.