Sha256: eb85ef10c7f331967b14760186a169f9142994e2fd183f561b8d23066dd9bd96
Contents?: true
Size: 737 Bytes
Versions: 30
Compression:
Stored size: 737 Bytes
Contents
class ::Exception def patch_full_message msg = [] msg << "\n#{backtrace.first} \n#{message} (#{self.class.to_s})" backtrace[1..-1].each_with_index {|bt, i| msg << "#{" "*8}#{i+1}: from #{bt}"} msg.join("\n") 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
30 entries across 30 versions & 1 rubygems