るりまサーチ (Ruby 2.3.0)

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.050秒)
トップページ > ライブラリ:ビルトイン[x] > バージョン:2.3.0[x] > クエリ:String[x] > クエリ:`[x] > クエリ:backtrace[x]

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub!

モジュール

キーワード

検索結果

Thread#backtrace -> [String] | nil (54721.0)

スレッドの現在のバックトレースを返します。

スレッドの現在のバックトレースを返します。

スレッドがすでに終了している場合は nil を返します。

//emlist[例][ruby]{
class C1
def m1
sleep 5
end
def m2
m1
end
end

th = Thread.new {C1.new.m2; Thread.stop}
th.backtrace
# => [
# [0] "(irb):3:in `sleep'",
# [1] "(irb):3:in `m1'",
# [2] "(irb):6:in `m2'",
# [3] ...

Exception#backtrace -> [String] (54685.0)

バックトレース情報を返します。

バックトレース情報を返します。

デフォルトでは

* "#{sourcefile}:#{sourceline}:in `#{method}'"
(メソッド内の場合)
* "#{sourcefile}:#{sourceline}"
(トップレベルの場合)

という形式の String の配列です。

//emlist[例][ruby]{
def methd
raise
end

begin
methd
rescue => e
p e.backtrace
end

#=> ["filename.rb:2:in `methd'", "filename.rb:6...

Exception#set_backtrace(errinfo) -> nil | String | [String] (19024.0)

バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。

バックトレース情報に errinfo を設定し、設定されたバックトレース
情報を返します。

@param errinfo nil、String あるいは String の配列のいずれかを指定します。

//emlist[例][ruby]{
begin
begin
raise "inner"
rescue
raise "outer"
end
rescue
$!.backtrace # => ["/path/to/test.rb:5:in `rescue in <main>'", "/path/to/test.rb:2:in `<main>'"]
$!.se...

Thread::Backtrace::Location#inspect -> String (9394.0)

Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文 字列に変換したオブジェクトを返します。

Thread::Backtrace::Location#to_s の結果を人間が読みやすいような文
字列に変換したオブジェクトを返します。

//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
puts call.inspect
end

# => "path/to/foo.rb:5:in ...

Thread::Backtrace::Location#to_s -> String (9346.0)

self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。

self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し
ます。

//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
puts call.to_s
end

# => path/to/foo.rb:5:in `initialize'
# path/to/foo...

絞り込み条件を変える

Kernel$$@ -> [String] | nil (364.0)

最後に例外が発生した時のバックトレースを表す配列です。 Kernel.#raise によって設定されます。

最後に例外が発生した時のバックトレースを表す配列です。
Kernel.#raise によって設定されます。

配列の各要素はメソッドの呼び出し位置を示す文字列で形式は

"filename:line"

または

"filename:line:in `methodname'"

です。これは Kernel.#caller が返す値と同じ形式です。

$@ へ値を代入するときは、$! が nil であってはいけません。
$@ の値は、$!.backtrace の値と同じです。
また、$@ への代入は $!.set_backtrace 呼び出しと同じです。

文字列の配列でも nil で...