lib/gurke/reporter.rb in gurke-3.3.4 vs lib/gurke/reporter.rb in gurke-3.3.5

- old
+ new

@@ -1,7 +1,9 @@ # frozen_string_literal: true +require 'stringio' + module Gurke # # A {Reporter} provides callbacks that will be executed whenever # a specific execution step starts or ends. # @@ -273,29 +275,29 @@ # @api private # protected - def format_exception(ex, backtrace: true, indent: 0) - s = StringIO.new - s << (' ' * indent) << ex.class.to_s << ': ' << ex.message.strip << "\n" + def format_exception(err, backtrace: true, indent: 0) + s = ::StringIO.new + s << (' ' * indent) << err.class.to_s << ': ' << err.message.strip << "\n" - if backtrace && ex.respond_to?(:backtrace) - if ex.backtrace.nil? + if backtrace && err.respond_to?(:backtrace) + if err.backtrace.nil? s << (' ' * indent) << ' <no backtrace available>' - elsif ex.backtrace.empty? + elsif err.backtrace.empty? s << (' ' * indent) << ' <backtrace empty>' else - ex.backtrace.each do |bt| + err.backtrace.each do |bt| s << (' ' * indent) << ' ' << bt.strip << "\n" end end end - if ex.respond_to?(:cause) && ex.cause && ex.cause.respond_to?(:message) + if err.respond_to?(:cause) && err.cause && err.cause.respond_to?(:message) s << (' ' * indent) << 'caused by: ' s << format_exception( - ex.cause, backtrace: backtrace, indent: indent + err.cause, backtrace: backtrace, indent: indent, ).strip end s.string end