Module: TemplateStreaming::ErrorRecovery::Rendering

Included in:
Helper, Middleware
Defined in:
lib/template_streaming/error_recovery.rb

Instance Method Summary collapse

Instance Method Details

#uncaught_error_string(error) ⇒ Object



19
20
21
22
23
# File 'lib/template_streaming/error_recovery.rb', line 19

def uncaught_error_string(error)
  details = "#{error.class}: #{error.message}"
  backtrace = error.backtrace.join("\n").gsub(/^/, '  ')
  "<span style='font-weight: bold; margin: 20px'>#{h details}</span>\n#{h backtrace}"
end

#uncaught_errors_html(errors) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/template_streaming/error_recovery.rb', line 7

def uncaught_errors_html(errors)
  content = errors.map do |error|
    "<pre>#{uncaught_error_string(error)}</pre>"
  end.join
  <<-EOS.gsub(/^ *\|/, '')
  |<div style='position: absolute; left: 0px; top: 0px; background-color: #fff; z-index: 999'>
  |  <h2 style="margin: 20px; font-weight: bold; border-bottom: 1px solid red">Rails Application Error</h2>
  |  #{content}
  |</div>
EOS
end