class Object
Public Instance Methods
ugh(short_message = 'unspecified ugh', **attr)
click to toggle source
# File lib/ugh.rb, line 42 def ugh short_message = 'unspecified ugh', **attr if short_message.is_a? Class then # Uh-oh, it's not a short message at all but an exception # class (or so we should hope). Let's instantiate it. raise short_message.new(**attr) else raise Ugh.new(short_message, **attr) end end
ugh?(klass = Ugh, **attributes) { || ... }
click to toggle source
# File lib/ugh.rb, line 55 def ugh? klass = Ugh, **attributes begin return yield rescue klass => exception evaluated_attributes = {} attributes.each_pair do |name, value| if value.is_a? Proc then unless exception.attributes.has_key? name then value = value.call else value = nil end end evaluated_attributes[name] = value end exception.attributes = evaluated_attributes.merge exception.attributes raise exception end end