diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-01 13:39:15 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-01 13:40:14 +0200 |
commit | 46611a995d91abf7bb2a64c62af13b6449c75b07 (patch) | |
tree | 1f2600e1c02142135ec8ea0f5309bb232c0997bf /actionpack/lib/action_view/renderer/streaming_template_renderer.rb | |
parent | 6960a230fa2c2b7cf59266fc903ce0c11e887a9f (diff) | |
download | rails-46611a995d91abf7bb2a64c62af13b6449c75b07.tar.gz rails-46611a995d91abf7bb2a64c62af13b6449c75b07.tar.bz2 rails-46611a995d91abf7bb2a64c62af13b6449c75b07.zip |
log errors when an exception happens when streaming.
Diffstat (limited to 'actionpack/lib/action_view/renderer/streaming_template_renderer.rb')
-rw-r--r-- | actionpack/lib/action_view/renderer/streaming_template_renderer.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/renderer/streaming_template_renderer.rb b/actionpack/lib/action_view/renderer/streaming_template_renderer.rb index d60b42a284..d987bc122a 100644 --- a/actionpack/lib/action_view/renderer/streaming_template_renderer.rb +++ b/actionpack/lib/action_view/renderer/streaming_template_renderer.rb @@ -60,11 +60,26 @@ module ActionView def each(&block) begin @start.call(block) - rescue + rescue Exception => exception + log_error(exception) block.call ActionView::Base.streaming_completion_on_exception end self end + + private + + # This is the same logging logic as in ShowExceptions middleware. + # TODO Once "exceptron" is in, refactor this piece to simply re-use exceptron. + def log_error(exception) #:nodoc: + logger = ActionController::Base.logger + return unless logger + + message = "\n#{exception.class} (#{exception.message}):\n" + message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code) + message << " " << exception.backtrace.join("\n ") + logger.fatal("#{message}\n\n") + end end # For streaming, instead of rendering a given a template, we return a Body |