8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/live_cable/connection/error_handling.rb', line 8
def handle_error(component, error)
Rails.error.report(error)
if LiveCable.configuration.verbose_errors
summary = "#{component.class.name} - #{error.class.name}: #{ERB::Util.html_escape(error.message)}"
backtrace_html = <<~HTML
<small>
<ol>
#{error.backtrace&.map { |line| "<li>#{ERB::Util.html_escape(line)}</li>" }&.join("\n")}
</ol>
</small>
HTML
else
summary = 'An error occurred'
end
html = <<~HTML
<details>
<summary style="color: #f00; cursor: pointer">#{summary}</summary>
#{backtrace_html}
</details>
HTML
component.rendered_children.each(&:destroy)
component.broadcast(_error: html)
end
|