From 65af7da0fb4fdf15c648ea0ead991d57dcdec6d9 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 19 Mar 2021 20:50:11 -0300 Subject: [PATCH] enviar los reportes --- app/jobs/backtrace_job.rb | 22 +++++++++---------- .../exception_notifier/_backtrace.text.erb | 2 ++ app/views/exception_notifier/_data.text.erb | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/jobs/backtrace_job.rb b/app/jobs/backtrace_job.rb index 1947bda6..b7c4ab90 100644 --- a/app/jobs/backtrace_job.rb +++ b/app/jobs/backtrace_job.rb @@ -12,25 +12,25 @@ class BacktraceJob < ApplicationJob @site_id = site_id @params = params - return if files.empty? + unless files.empty? + params['errors'].each do |error| + error['backtrace'].each do |backtrace| + offset = SourceMap::Offset.new(backtrace['line'], backtrace['column']) + mapping = sourcemap.bsearch(offset) - params['errors'].each do |error| - error['backtrace'].each do |backtrace| - offset = SourceMap::Offset.new(backtrace['line'], backtrace['column']) - mapping = sourcemap.bsearch(offset) + next unless mapping - next unless mapping - - backtrace['file'] = mapping.source - backtrace['line'] = mapping.original.line - backtrace['column'] = mapping.original.column + backtrace['file'] = mapping.source + backtrace['line'] = mapping.original.line + backtrace['column'] = mapping.original.column + end end end begin raise BacktraceException, params['errors']&.first&.dig('message') rescue BacktraceException => e - ExceptionNotifier.notify_exception(e, data: { site: site.name, params: params, backtrace: true }) + ExceptionNotifier.notify_exception(e, data: { site: site.name, params: params, _backtrace: true }) end end diff --git a/app/views/exception_notifier/_backtrace.text.erb b/app/views/exception_notifier/_backtrace.text.erb index 9631be28..d62b5719 100644 --- a/app/views/exception_notifier/_backtrace.text.erb +++ b/app/views/exception_notifier/_backtrace.text.erb @@ -1,3 +1,5 @@ +<% unless @data[:_backtrace] %> ``` <%= raw @backtrace.join("\n") %> ``` +<% end %> diff --git a/app/views/exception_notifier/_data.text.erb b/app/views/exception_notifier/_data.text.erb index 050950e8..f2195b9a 100644 --- a/app/views/exception_notifier/_data.text.erb +++ b/app/views/exception_notifier/_data.text.erb @@ -1,4 +1,4 @@ -<% if @data['backtrace'] %> +<% if @data[:_backtrace] %> <% @data.dig(:params, 'errors')&.each do |error| %> # <%= error['type'] %>: <%= error['message'] %>