application controller: clean up exception handling.
* Simplify code. * Show backtraces for all users, not just builders. * Show backtraces only for unexpected server errors (status 5xx), not for normal client errors (status 4xx). * Log expected errors at info level (reduce noise in production logs).
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
<% if @error_message %>
|
||||
{"success": false, "message": <%= raw @error_message.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>}
|
||||
<% else %>
|
||||
{
|
||||
"success": false,
|
||||
"message": <%= raw @exception.to_s.encode("utf-8", {:invalid => :replace, :undef => :replace, :replace => "?"}).to_json %>,
|
||||
"backtrace": <%= raw Rails.backtrace_cleaner.clean(@exception.backtrace).to_json %>
|
||||
}
|
||||
<% end %>
|
||||
{
|
||||
"success": false,
|
||||
"message": <%= raw @message.to_json %>,
|
||||
"backtrace": <%= raw @backtrace.to_json %>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user