るりまサーチ

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

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Exception#backtrace -> [String] (18138.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] (6283.0)

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

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

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

//emlist[例: test.rb][ruby]{
require "date"
def check_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 Exc...
...eption#backtrace...

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

バックトレース情報に 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>'"]
$!.set_backtrace(["dummy1", "dummy2"])
$!.backtrace # => ["dummy1", "dummy2"]
end

//}...

Thread::Backtrace::Location#base_label -> String (3059.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 (3047.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 (3043.0)

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

...list[例][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...

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

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.rb:9:...

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

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

...スを指定できます。

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

//emlist[例][ruby]{
f = Fiber.new { Fiber.yiel...
...d }
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 (59.0)

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

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

@
param other 自身と比較したいオブジェクトを指定します。...
...て変換を試みます。

//emlist[例][ruby]{
require "date"
def 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_exceptio...
...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 > >>