mercredi 29 juillet 2015

Ruby on Rails 3: Streaming data and catching exception

I'm streaming data using the following approach:

self.response_body = Enumerator.new do |y|
    10_000_000.times do |i|
        y << "This is line #{i}\n"
    end
end

I'm trying to catch any exception generated inside Enumerator and present something nicer to the user. Right now, the app is presenting an ugly error page from Torquebox. e.g.

Torquebox/Jboss error page.

I tried rescue and redirect_to and many other ways to catch the exception (including add a middleware class for handling exceptions). Any help would be appreciated!.

(The app is made under jruby v1.7.19 and torquebox v3.1.1)

Aucun commentaire:

Enregistrer un commentaire