Skip to content

Commit

Permalink
Display error message for rendering errors
Browse files Browse the repository at this point in the history
  • Loading branch information
UweKubosch committed Jan 31, 2023
1 parent f6f74cc commit 38a9871
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/main/resources/ruby/slim_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,17 @@ def params.[](key)
html
end
rescue Exception => e # rubocop: disable Lint/RescueException
LOG.error "Exception rendering view: #{rendering_context.url.inspect}"
LOG.error "#{e.class}: #{e.message}"
LOG.info e.backtrace.join("\n")
LOG.error e
raise
message = <<~HTML
Exception rendering view: #{rendering_context.url.inspect}
#{e.class}: #{e.message}
#{e}
#{e.backtrace.join("\n")}
HTML
LOG.error message
"<h1>Whoops!</h1><pre>#{message}</pre>"
end

# self in this context is the Struct with the context variables
Expand Down

0 comments on commit 38a9871

Please sign in to comment.