Sha256: 80cae1ad2cf79a2e6a84397713482994be1b321322eaa6b731874200d6376381
Contents?: true
Size: 1000 Bytes
Versions: 86
Compression:
Stored size: 1000 Bytes
Contents
class ::Exception def patch_full_message begin msg = [] tracing = backtrace ? backtrace : [] tracing = (self.class == SystemStackError) ? tracing[1..30] : tracing[1..-1] tracing ||= [] msg << "\n#{tracing.first} \n#{message} (#{self.class.to_s})" tracing.each_with_index {|bt, i| msg << "#{" "*8}#{i+1}: from #{bt}"} msg.join("\n") rescue Exception => e puts "Something is wrong with 'patch_full_message': #{e}" end 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 self.extend mod end def append_message(message) mod = Module.new do define_method :to_s do super() + String(message) end end self.extend mod end end
Version data entries
86 entries across 86 versions & 1 rubygems