Method: Object#try

Defined in:
lib/y_support/try.rb

#try(receiver_NL_description = self, attempt_NL_description, &block) ⇒ Object Also known as: consciously

Try method takes two textual arguments and one block. The first (optional) argument is a natural language description of the method’s receiver (with #to_s of the receiver used by default). The second argument is a natural language description of the supplied block’s contract – in other words, what the supplied block tries to do. Finally, the block contains the code to perform the described risky action. Inside the block, #note method is available, which builds up the context information for a good error message, should the risky action raise one.



127
128
129
130
131
# File 'lib/y_support/try.rb', line 127

def try receiver_NL_description=self, attempt_NL_description, &block
  Consciously::Try.new( object: receiver_NL_description,
                       text: attempt_NL_description,
                       &block ).__invoke__
end