Exception: LocalJumpError
- Inherits:
-
StandardError
- Object
- Exception
- StandardError
- LocalJumpError
- Defined in:
- proc.c
Overview
Raised when Ruby can't yield as requested.
A typical scenario is attempting to yield when no block is given:
def call_block
yield 42
end
call_block
raises the exception:
LocalJumpError: no block given (yield)
A more subtle example:
def get_me_a_return
Proc.new { return 42 }
end
get_me_a_return.call
raises the exception:
LocalJumpError: unexpected return
Instance Method Summary collapse
-
#exit_value ⇒ Object
call_seq: local_jump_error.exit_value -> obj.
-
#reason ⇒ Object
The reason this block was terminated: :break, :redo, :retry, :next, :return, or :noreason.
Methods inherited from Exception
#==, #backtrace, #exception, exception, #initialize, #inspect, #message, #set_backtrace, #to_s
Constructor Details
This class inherits a constructor from Exception
Instance Method Details
#exit_value ⇒ Object
call_seq:
local_jump_error.exit_value -> obj
Returns the exit value associated with this LocalJumpError
.
|
# File 'proc.c'
/*
* call_seq:
* local_jump_error.exit_value -> obj
*
* Returns the exit value associated with this +LocalJumpError+.
*/
static VALUE
localjump_xvalue(VALUE exc)
{
return rb_iv_get(exc, "@exit_value");
}
|
#reason ⇒ Object
The reason this block was terminated: :break, :redo, :retry, :next, :return, or :noreason.
|
# File 'proc.c'
/*
* call-seq:
* local_jump_error.reason -> symbol
*
* The reason this block was terminated:
* :break, :redo, :retry, :next, :return, or :noreason.
*/
static VALUE
localjump_reason(VALUE exc)
{
return rb_iv_get(exc, "@reason");
}
|