るりまサーチ

最速Rubyリファレンスマニュアル検索!
125件ヒット [1-100件を表示] (0.124秒)

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. io seek_end

ライブラリ

キーワード

検索結果

<< 1 2 > >>

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

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

...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] "(irb):10:in `block in irb_binding'"
# ]

th.kill
th.backtrace # => nil
//}...

Exception#backtrace -> [String] (18126.0)

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

...)
* "#{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"]
//}

@see Exception#backtrace_locations...

Exception#backtrace_locations -> [Thread::Backtrace::Location] (6271.0)

バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。

...バックトレース情報を返します。Exception#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。

現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。

//emlist[例: test.rb][ruby]{
require...
...return if Date.new(2000, month, -1).day == 31
raise "#{month} is not long month"
end


def get_exception
return begin
yield
rescue => e
e
end

end


e = get_exception { check_long_month(2) }
p e.backtrace_locations
# => ["test.rb:4:in `check_long_month'", "test.rb:15:in `block in <main...
...>'", "test.rb:9:in `get_exception'", "test.rb:15:in `<main>'"]
//}

@see Exception#backtrace...

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

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

...定します。

//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>'"]
$!.set_backtrace(["dummy1", "dummy2"])
$!.backtrace # => ["dummy1", "dummy2"]
end

//}...

Thread::Backtrace::Location#base_label -> String (3041.0)

self が表すフレームの基本ラベルを返します。通常、 Thread::Backtrace::Location#label から修飾を取り除いたもので構成 されます。

...d::Backtrace::Location#label から修飾を取り除いたもので構成
されます。

//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.base_label
end


#...
...=> initialize
# new
# <main>
//}

@see Thread::Backtrace::Location#label...

絞り込み条件を変える

Thread::Backtrace::Location#inspect -> String (3035.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).loc...
...ations.map do |call|
puts call.inspect
end


# => "path/to/foo.rb:5:in `initialize'"
# "path/to/foo.rb:9:in `new'"
# "path/to/foo.rb:9:in `<main>'"
//}...

Thread::Backtrace::Location#absolute_path -> String (3025.0)

self が表すフレームの絶対パスを返します。

...][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.absolute_path
end


# => /path/to/foo.rb
# /path/to/foo.rb
# /path/to/foo.rb
//}

@see Thread::Backtrace::Location#path...

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

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

...mlist[例][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.rb:9:in `new'
# path/to/foo.rb:9:in `<main>'
//}...

Fiber#raise(exception, message = nil, backtrace = nil) -> object (120.0)

selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。

...指定できます。

@param message 例外のメッセージとなる文字列です。
@param exception 発生させる例外です。
@param backtrace 例外発生時のスタックトレースです。文字列の配列で指定します。

//emlist[例][ruby]{
f = Fiber.new { Fiber.yield }
f....
...resume
f.raise "Error!" # => Error! (RuntimeError)
//}

//emlist[ファイバー内のイテレーションを終了させる例][ruby]{
f = Fiber.new do
loop do
Fiber.yield(:loop)
end

:exit
end


p f.resume # => :loop
p f.raise StopIteration # => :exit
//}...

Exception#==(other) -> bool (47.0)

自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。

...自身と指定された other のクラスが同じであり、
message と backtrace が == メソッドで比較して
等しい場合に true を返します。そうでない場合に false を返します。

@param other 自身と比較したいオブジェクトを指定します。...
...ef check_long_month(month)
return if Date.new(2000, month, -1).day == 31
raise "#{month} is not long month"
end


def get_exception
return begin
yield
rescue => e
e
end

end


results = [2, 2, 4].map { |e | get_exception { check_long_month(e) } }
p results.map { |e| e.class }
# => [Ru...
...ge }
# => ["2 is not long month", "2 is not long month", "4 is not long month"]

# class, message, backtrace が同一のため true になる
p results[0] == results[1] # => true

# class, backtrace が同一だが、message がことなるため false になる
p results[0] == results[2] # =...

絞り込み条件を変える

<< 1 2 > >>