Exception: LocalJumpError
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::StandardError ,
::Exception
|
|
Instance Chain:
self,
::StandardError ,
::Exception
|
|
Inherits: |
StandardError
|
Defined in: | proc.c, 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
Class Attribute Summary
::Exception
- Inherited
.to_tty? | Returns |
Class Method Summary
::Exception
- Inherited
.exception | Returns an exception object of the same class as |
.new | Returns a new exception object. |
Instance Method Summary
-
#exit_value ⇒ Object
Returns the exit value associated with this
LocalJumpError
. -
#reason ⇒ Symbol
The reason this block was terminated:
:break
,:redo
,:retry
,:next
,:return
, or:noreason
.
::Exception
- Inherited
#== | Returns whether |
#backtrace | Returns a backtrace value for |
#backtrace_locations | Returns a backtrace value for |
#cause | Returns the previous value of global variable |
#detailed_message | Returns the message string with enhancements: |
#exception | Returns an exception object of the same class as |
#full_message | Returns an enhanced message string: |
#inspect | Returns a string representation of |
#message | Returns |
#set_backtrace | Sets the backtrace value for |
#to_s | Returns a string representation of |
Constructor Details
This class inherits a constructor from Exception
Instance Method Details
#exit_value ⇒ Object
Returns the exit value associated with this LocalJumpError
.
# File 'proc.c', line 3410
static VALUE localjump_xvalue(VALUE exc) { return rb_iv_get(exc, "@exit_value"); }
#reason ⇒ Symbol
The reason this block was terminated: :break
, :redo
, :retry
, :next
, :return
, or :noreason
.
# File 'proc.c', line 3424
static VALUE localjump_reason(VALUE exc) { return rb_iv_get(exc, "@reason"); }