種類
- モジュール関数 (132)
- インスタンスメソッド (33)
- 変数 (11)
- クラス (11)
ライブラリ
- ビルトイン (187)
クラス
- Thread (22)
-
Thread
:: Backtrace :: Location (11)
モジュール
- Kernel (143)
キーワード
-
$ @ (11) - Location (11)
-
backtrace
_ locations (22) -
caller
_ locations (22) - fail (33)
- raise (33)
-
set
_ trace _ func (11) -
to
_ s (11)
検索結果
先頭5件
-
Kernel
. # caller(range) -> [String] | nil (47217.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...情報を $@
の形式のバックトレース(文字列の配列)として返します。
トップレベルでは空の配列を返します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を......範囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'......caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(cal... -
Kernel
. # caller(start = 1) -> [String] | nil (47217.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...情報を $@
の形式のバックトレース(文字列の配列)として返します。
トップレベルでは空の配列を返します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を......範囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'......caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(cal... -
Kernel
. # caller(start , length) -> [String] | nil (47217.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...情報を $@
の形式のバックトレース(文字列の配列)として返します。
トップレベルでは空の配列を返します。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を......範囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'......caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(cal... -
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (35126.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(start, length)
end
caller_locations # => []
test3(1, nil)
# => ["/......(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}
@see Thread::Backtrace::Location, Kernel.#caller... -
Kernel
. # caller _ locations(start = 1 , length = nil) -> [Thread :: Backtrace :: Location] | nil (35126.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(start, length)
end
caller_locations # => []
test3(1, nil)
# => ["/......(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}
@see Thread::Backtrace::Location, Kernel.#caller... -
Kernel
. # fail(error _ type , message = nil , backtrace = caller(0) , cause: $ !) -> () (29126.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...ます。
@param message 例外のメッセージとなる文字列です。
@param backtrace 例外発生時のスタックトレースで、Kernel.#caller の戻り値と同じ
形式で指定しなければいけません。
@param cause 現在の例外($!)の代わりに Exception#cause に設......end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyException
def exception(mesg=nil)
SecurityError.new(mesg)
end
end
begin
raise MyException.new
rescue SecurityError
p $! #=> #<SecurityError: SecurityError>
end
//}
@see Kernel.#caller... -
Kernel
. # raise(error _ type , message = nil , backtrace = caller(0) , cause: $ !) -> () (29126.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...ます。
@param message 例外のメッセージとなる文字列です。
@param backtrace 例外発生時のスタックトレースで、Kernel.#caller の戻り値と同じ
形式で指定しなければいけません。
@param cause 現在の例外($!)の代わりに Exception#cause に設......end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyException
def exception(mesg=nil)
SecurityError.new(mesg)
end
end
begin
raise MyException.new
rescue SecurityError
p $! #=> #<SecurityError: SecurityError>
end
//}
@see Kernel.#caller... -
Kernel
$ $ @ -> [String] | nil (29028.0) -
最後に例外が発生した時のバックトレースを表す配列です。 Kernel.#raise によって設定されます。
...レースを表す配列です。
Kernel.#raise によって設定されます。
配列の各要素はメソッドの呼び出し位置を示す文字列で形式は
"filename:line"
または
"filename:line:in `methodname'"
です。これは Kernel.#caller が返す値と同じ形式で... -
Kernel
. # fail -> () (29026.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...ます。
@param message 例外のメッセージとなる文字列です。
@param backtrace 例外発生時のスタックトレースで、Kernel.#caller の戻り値と同じ
形式で指定しなければいけません。
@param cause 現在の例外($!)の代わりに Exception#cause に設......end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyException
def exception(mesg=nil)
SecurityError.new(mesg)
end
end
begin
raise MyException.new
rescue SecurityError
p $! #=> #<SecurityError: SecurityError>
end
//}
@see Kernel.#caller... -
Kernel
. # fail(message , cause: $ !) -> () (29026.0) -
例外を発生させます。 発生した例外は変数 $! に格納されます。また例外が 発生した時のスタックトレースは変数 $@ に格納され ます。発生した例外は rescue 節で捕捉できます。
...ます。
@param message 例外のメッセージとなる文字列です。
@param backtrace 例外発生時のスタックトレースで、Kernel.#caller の戻り値と同じ
形式で指定しなければいけません。
@param cause 現在の例外($!)の代わりに Exception#cause に設......end
foo(4) #=> in method.in rescue.in method.in else.in ensure.
//}
//emlist[例3][ruby]{
class MyException
def exception(mesg=nil)
SecurityError.new(mesg)
end
end
begin
raise MyException.new
rescue SecurityError
p $! #=> #<SecurityError: SecurityError>
end
//}
@see Kernel.#caller...