Clean backtraces in uploads/show, static/error.json.
This commit is contained in:
8
app/javascript/src/styles/specific/error.scss
Normal file
8
app/javascript/src/styles/specific/error.scss
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
ul.backtrace {
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 1.2em;
|
||||||
|
list-style-type: none;
|
||||||
|
background: #EEE;
|
||||||
|
padding: 1em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
7
app/views/static/_backtrace.html.erb
Normal file
7
app/views/static/_backtrace.html.erb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<%# backtrace %>
|
||||||
|
|
||||||
|
<ul class="backtrace">
|
||||||
|
<% Rails.backtrace_cleaner.clean(backtrace).each do |b| %>
|
||||||
|
<li class="backtrace-line"><%= b %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
<% if CurrentUser.user.try(:is_builder?) && @exception.present? %>
|
<% if CurrentUser.user.try(:is_builder?) && @exception.present? %>
|
||||||
<h1><%= @exception.class.to_s %> exception raised</h1>
|
<h1><%= @exception.class.to_s %> exception raised</h1>
|
||||||
<ul style="font-family: monospace; font-size: 1.2em; list-style-type: none;">
|
|
||||||
<li><%= @exception.message.dup.force_encoding("utf-8") %></li>
|
<p><%= @exception.message.dup.force_encoding("utf-8") %></p>
|
||||||
<%- Rails.backtrace_cleaner.clean(@exception.backtrace).each do |b| -%>
|
<%= render "static/backtrace", backtrace: @exception.backtrace %>
|
||||||
<li style="list-style-type: none;"><%= b %></li>
|
|
||||||
<%- end -%>
|
|
||||||
</ul>
|
|
||||||
<% elsif @error_message %>
|
<% elsif @error_message %>
|
||||||
<p><%= @error_message %></p>
|
<p><%= @error_message %></p>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
{
|
{
|
||||||
"success": false,
|
"success": false,
|
||||||
"message": <%= raw @exception.to_s.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>,
|
"message": <%= raw @exception.to_s.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>,
|
||||||
"backtrace": <%= raw @exception.backtrace.to_json %>
|
"backtrace": <%= raw Rails.backtrace_cleaner.clean(@exception.backtrace).to_json %>
|
||||||
}
|
}
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -30,11 +30,7 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<p>An error occurred: <%= render_status(@upload) %></p>
|
<p>An error occurred: <%= render_status(@upload) %></p>
|
||||||
<% if CurrentUser.user.is_builder? %>
|
<% if CurrentUser.user.is_builder? %>
|
||||||
<ul>
|
<%= render "static/backtrace", backtrace: @upload.backtrace.to_s.split(/\n/) %>
|
||||||
<% @upload.backtrace.to_s.split(/\n/).each do |line| %>
|
|
||||||
<li><%= line %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user