Class: Nydp::Builtin::HandleError::CatchError
- Includes:
- Helper, VM::HandleError
- Defined in:
- lib/nydp/builtin/handle_error.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#vm_arg_array_size ⇒ Object
readonly
Returns the value of attribute vm_arg_array_size.
Instance Method Summary collapse
- #execute(vm) ⇒ Object
-
#initialize(handler, vm_arg_array_size) ⇒ CatchError
constructor
A new instance of CatchError.
- #to_s ⇒ Object
Methods included from Helper
#cons, #list, #literal?, #pair?, #sig, #sym, #sym?
Methods included from Converter
Constructor Details
#initialize(handler, vm_arg_array_size) ⇒ CatchError
Returns a new instance of CatchError.
11 12 13 |
# File 'lib/nydp/builtin/handle_error.rb', line 11 def initialize handler, vm_arg_array_size @handler, @vm_arg_array_size = handler, vm_arg_array_size end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
9 10 11 |
# File 'lib/nydp/builtin/handle_error.rb', line 9 def handler @handler end |
#vm_arg_array_size ⇒ Object (readonly)
Returns the value of attribute vm_arg_array_size.
9 10 11 |
# File 'lib/nydp/builtin/handle_error.rb', line 9 def vm_arg_array_size @vm_arg_array_size end |
Instance Method Details
#execute(vm) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nydp/builtin/handle_error.rb', line 15 def execute vm e = vm.last_error = vm.unhandled_error vm.unhandled_error = nil return unless e vm.args = vm.args[0...vm_arg_array_size] msgs = [] while e msgs << e. e = e.cause end handler.invoke_2 vm, r2n(msgs) end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/nydp/builtin/handle_error.rb', line 31 def to_s "(on-err: #{handler})" end |