63件ヒット
[1-63件を表示]
(0.073秒)
ライブラリ
- ビルトイン (63)
クラス
- Exception (32)
- Object (12)
- Thread (12)
- TracePoint (7)
キーワード
-
backtrace
_ locations (12) -
instruction
_ sequence (7) -
respond
_ to? (12) -
set
_ backtrace (12)
検索結果
先頭5件
-
Thread
# raise(error _ type , message , traceback) -> () (18132.0) -
自身が表すスレッドで強制的に例外を発生させます。
...させます。
@param error_type Kernel.#raise を参照してください。
@param message Kernel.#raise を参照してください。
@param traceback Kernel.#raise を参照してください。
Thread.new {
sleep 1
Thread.main.raise "foobar"
}
begin
sleep
rescue
p... -
Exception
# full _ message(highlight: true , order: :bottom) -> String (25.0) -
例外の整形された文字列を返します。
...。
//emlist[例][ruby]{
begin
raise "test"
rescue => e
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:2:in `<main>': \e[1mtest (\e[4;1mRuntimeError\e[m\e[1m)\n\e[m"
$stderr = $stdout
p e.full_message # => "test.rb:2:in `<main>': test (RuntimeError)\n"
$st......derr = STDERR
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:2:in `<main>': \e[1mtest (\e[4;1mRuntimeError\e[m\e[1m)\n\e[m"
end
//}
@see Exception.to_tty?... -
Exception
# set _ backtrace(errinfo) -> nil | String | [String] (25.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"... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (19.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...0, 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... -
Object
# respond _ to?(name , include _ all = false) -> bool (13.0) -
オブジェクトがメソッド name を持つとき真を返します。
...hello if it.respond_to?(:hello, true)")}
#=> Bonjour
# Guten Tag
module Template
def main
start
template_method
finish
end
def start
puts "start"
end
def template_method
raise NotImplementedError.new
end
def finish
puts "finish"
end
end
class ImplTempl... -
TracePoint
# instruction _ sequence -> RubyVM :: InstructionSequence (13.0) -
script_compiledイベント発生時にコンパイルされた RubyVM::InstructionSequenceインスタンスを返します。
...]{
TracePoint.new(:script_compiled) do |tp|
p tp.instruction_sequence # => <RubyVM::InstructionSequence:block in <main>@(eval):1>
end.enable do
eval("puts 'hello'")
end
//}
@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行...