Clean backtraces in uploads/show, static/error.json.

This commit is contained in:
evazion
2018-09-23 11:44:45 -05:00
parent 3414d27c78
commit b4cf423058
5 changed files with 21 additions and 13 deletions

View 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;
}

View 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>

View File

@@ -1,11 +1,8 @@
<% if CurrentUser.user.try(:is_builder?) && @exception.present? %>
<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>
<%- Rails.backtrace_cleaner.clean(@exception.backtrace).each do |b| -%>
<li style="list-style-type: none;"><%= b %></li>
<%- end -%>
</ul>
<h1><%= @exception.class.to_s %> exception raised</h1>
<p><%= @exception.message.dup.force_encoding("utf-8") %></p>
<%= render "static/backtrace", backtrace: @exception.backtrace %>
<% elsif @error_message %>
<p><%= @error_message %></p>
<% else %>

View File

@@ -4,6 +4,6 @@
{
"success": false,
"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 %>

View File

@@ -30,11 +30,7 @@
<% else %>
<p>An error occurred: <%= render_status(@upload) %></p>
<% if CurrentUser.user.is_builder? %>
<ul>
<% @upload.backtrace.to_s.split(/\n/).each do |line| %>
<li><%= line %></li>
<% end %>
</ul>
<%= render "static/backtrace", backtrace: @upload.backtrace.to_s.split(/\n/) %>
<% end %>
<% end %>