Module: NeverGonnaLetYouDown

Included in:
Object
Defined in:
lib/unixcmd/aux.rb

Instance Method Summary collapse

Instance Method Details

#fail(exception = RuntimeError, string = nil, array = caller) ⇒ Object

Raises:

  • (exception)


173
174
175
# File 'lib/unixcmd/aux.rb', line 173

def fail(exception = RuntimeError, string = nil, array = caller)
  raise(exception, string, array)
end

#raise(exception = RuntimeError, string = nil, array = caller) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/unixcmd/aux.rb', line 157

def raise(exception = RuntimeError, string = nil, array = caller)
  # With a single String argument, raises a
  # RuntimeError with the string as a message. 
  if exception.is_a?(String)
    string = exception
    exception = RuntimeError
  end
  
  callcc do |cc|
    obj = exception.exception(string)
    obj.set_backtrace(array)
    obj.continuation = cc
    super obj
  end
end