[Rails] Re: Hook into Exception Chain

2013-11-18 Thread sol
Thanks a lot! That's useful On Saturday, 16 November 2013 22:36:35 UTC+1, Frederick Cheung wrote: > > > > On Friday, November 15, 2013 10:26:10 AM UTC, sol wrote: >> >> I've used the above approach now >> >> However, this only works for controller actions. >> I've got some cronjobs in the project

[Rails] Re: Hook into Exception Chain

2013-11-16 Thread Frederick Cheung
On Friday, November 15, 2013 10:26:10 AM UTC, sol wrote: > > I've used the above approach now > > However, this only works for controller actions. > I've got some cronjobs in the project (lib folder) as well as a sinatra > app that is mounted within the rails app. > > Is there any way I could ca

[Rails] Re: Hook into Exception Chain

2013-11-15 Thread sol
I've used the above approach now However, this only works for controller actions. I've got some cronjobs in the project (lib folder) as well as a sinatra app that is mounted within the rails app. Is there any way I could catch the exceptions in these parts as well? Thanks, Christoph On Tuesday

[Rails] Re: Hook into Exception Chain

2013-11-12 Thread sol
Thanks a lot Jeff, Yeah I saw it works, that's why I wondered about the linked post.. Anyway, I'm just trying to basically get emails that contain the exception/error message in the subject so it's easier to sort if there are many error mails. Of course the rescue_from method only targets one s

[Rails] Re: Hook into Exception Chain

2013-11-12 Thread Jeff Lewis
Hi Christoph, My (simple) example was just trying to give you an idea of how to do what you were asking using rescue_from. And note that the log does show that the re-raising worked as expected, where we did something with the caught exception first (ie write a debug TEST line to the log) befo

[Rails] Re: Hook into Exception Chain

2013-11-12 Thread sol
Hi Jeff, thanks for your reply! I found the article here: http://www.simonecarletti.com/blog/2009/11/re-raise-a-ruby-exception-in-a-rails-rescue_from-statement/ And he mentions that re-raising does not work since rails won't catch it anymore.. has this been changed since? I generally thought th

[Rails] Re: Hook into Exception Chain

2013-11-12 Thread Jeff Lewis
Hi Christoph, All you need to do is re-raise the exception after you're done using it in your rescue_from, so something along the lines of: $ cat ./app/controllers/foo_controller.rb ... rescue_from Exception do |e| # do something with e before re-raising it ... Rails.logger.debug("TEST