lib/rorvswild.rb in rorvswild-0.4.0 vs lib/rorvswild.rb in rorvswild-0.4.1
- old
+ new
@@ -82,11 +82,11 @@
if defined?(Rails)
@logger ||= Rails.logger
@app_root ||= Rails.root.to_s
config = Rails.application.config
@parameter_filter = ActionDispatch::Http::ParameterFilter.new(config.filter_parameters)
- @ignored_exceptions = %w[ActionController::RoutingError] + config.action_dispatch.rescue_responses.map { |(key,value)| key }
+ @ignored_exceptions ||= %w[ActionController::RoutingError] + config.action_dispatch.rescue_responses.map { |(key,value)| key }
end
@logger ||= Logger.new(STDERR)
@app_root_regex = app_root ? /\A#{app_root}/ : nil
@@ -148,11 +148,11 @@
end
end
end
def after_exception(exception, controller)
- if !ignored_exceptions.include?(exception.class.to_s)
+ if !ignored_exception?(exception)
file, line = exception.backtrace.first.split(":")
request[:error] = exception_to_hash(exception).merge(
session: controller.session.to_hash,
environment_variables: filter_sensitive_data(filter_environment_variables(controller.request.env))
)
@@ -183,12 +183,12 @@
job[:queries] = []
started_at = Time.now
cpu_time_offset = cpu_time
begin
block.call
- rescue Exception => exception
- job[:error] = exception_to_hash(exception)
+ rescue Exception => ex
+ job[:error] = exception_to_hash(ex) if !ignored_exception?(ex)
raise
ensure
job[:runtime] = (Time.now - started_at) * 1000
job[:cpu_runtime] = (cpu_time - cpu_time_offset) * 1000
post_job
@@ -196,13 +196,13 @@
end
def catch_error(extra_details = nil, &block)
begin
block.call
- rescue Exception => exception
- record_error(exception, extra_details)
- exception
+ rescue Exception => ex
+ record_error(ex, extra_details) if !ignored_exception?(ex)
+ ex
end
end
def record_error(exception, extra_details = nil)
post_error(exception_to_hash(exception, extra_details))
@@ -381,9 +381,13 @@
@parameter_filter ? @parameter_filter.filter(hash) : hash
end
def filter_environment_variables(hash)
hash.clone.keep_if { |key,value| key == key.upcase }
+ end
+
+ def ignored_exception?(exception)
+ ignored_exceptions.include?(exception.class.to_s)
end
def log_error(exception)
@logger.error("[RorVsWild] " + exception.inspect)
@logger.error("[RorVsWild] " + exception.backtrace.join("\n[RorVsWild] "))