Sha256: 06d66e4cb1cd6a52b3bb16cbf088976945383cef534765bdf763b438f7c49f99
Contents?: true
Size: 1005 Bytes
Versions: 1
Compression:
Stored size: 1005 Bytes
Contents
class ::Exception def patch_full_message(trace_count: -1) tracing = backtrace || [] tracing = tracing[1..trace_count] tracing = tracing[1..30] if instance_of?(SystemStackError) tracing ||= [] msg = [] msg << "\n#{tracing.first} \n#{message} (#{self.class})" tracing.each_with_index do |bt, i| msg << "#{" " * 8}#{i + 1}: from #{bt}" end msg.join("\n") rescue StandardError => e puts "Something is wrong with 'patch_full_message': #{e}" end end # To extend an exception message preserving same exception object # @see https://stackoverflow.com/a/30133010/4352306 Exception.class_eval do def prepend_message(message) mod = Module.new do define_method :to_s do String(message) + super() end end extend mod end def append_message(message) mod = Module.new do define_method :to_s do super() + String(message) end end extend mod end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eco-helpers-2.7.19 | lib/eco/api/common/version_patches/exception.rb |