Provides cascading errors with formatted messages. See the specs for details.
# File lib/backup/errors.rb, line 8 def self.included(klass) klass.extend Module.new { def wrap(wrapped_exception, msg = nil) new(msg, wrapped_exception) end } end
# File lib/backup/errors.rb, line 16 def initialize(obj = nil, wrapped_exception = nil) @wrapped_exception = wrapped_exception msg = (obj.respond_to?(:to_str) ? obj.to_str : obj.to_s). gsub(/^ */, ' ').strip msg = clean_name(self.class.name) + (msg.empty? ? '' : ": #{ msg }") if wrapped_exception msg << "\n--- Wrapped Exception ---\n" class_name = clean_name(wrapped_exception.class.name) msg << class_name + ': ' unless wrapped_exception.message.start_with? class_name msg << wrapped_exception.message end super(msg) set_backtrace(wrapped_exception.backtrace) if wrapped_exception end
Generated with the Darkfish Rdoc Generator 2.