モジュール
キーワード
- == (12)
- Fail (6)
- Raise (6)
- backtrace (12)
-
backtrace
_ locations (12) - cause (12)
- exception (24)
- fail (6)
- inspect (12)
-
raised
_ exception (12) -
read
_ nonblock (24) -
report
_ on _ exception (9) -
report
_ on _ exception= (9) -
set
_ backtrace (12) -
write
_ nonblock (12)
検索結果
先頭5件
-
Exception
# set _ backtrace(errinfo) -> nil | String | [String] (3013.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_ba... -
Exception
# ==(other) -> bool (3007.0) -
自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。
...トを指定した場合は
Exception#exception を実行して変換を試みます。
//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_exception { check_long_month(e) } }
p results.map { |e| e.class }
# => [RuntimeError, RuntimeError, RuntimeError]
p results.map { |e| e.message }
# => ["2 is not long month", "2 is not long month", "4 is not long month"]
# class, mess... -
Exception
# backtrace -> [String] (3007.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] (3007.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...バックトレース情報を返します。Exception#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require......ay == 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
# full _ message(highlight: true , order: :bottom) -> String (3007.0) -
例外の整形された文字列を返します。
...値は Exception.to_tty? の返り値と同じです。
@param order :top か :bottom で指定する必要があります。
バックトレースの一番奥がエラーメッセージの上(top)か下(bottom)かを指定します。
デフォルト値は Exception.to_tt......y? が真なら :bottom で偽なら :top です。
//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 # => "tes......t.rb:2:in `<main>': test (RuntimeError)\n"
$stderr = 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
# inspect -> String (3007.0) -
self のクラス名と message を文字列にして返します。
...self のクラス名と message を文字列にして返します。
//emlist[例][ruby]{
begin
raise "exception"
rescue
p $!.inspect # => "#<RuntimeError: exception>"
end
//}... -
IO
# read _ nonblock(maxlen , outbuf = nil , exception: true) -> String | Symbol | nil (119.0) -
IO をノンブロッキングモードに設定し、 その後で read(2) システムコールにより 長さ maxlen を上限として読み込み、文字列として返します。 EAGAIN, EINTR などは Errno::EXXX 例外として呼出元に報告されます。
...込んだデータのサイズになります。read(2) システムコールが 0 を返した場合は、空文字列になります。
@param exception 読み込み時に Errno::EAGAIN、
Errno::EWOULDBLOCK が発生する代わりに
:wait_readable を返すか......の代わりに nil を返します。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
@raise Errno::EXXX read(2) システムコールの結果としてエラーが起きた場合に発生します。
@raise EOFError read(2) システムコール... -
IO
# write _ nonblock(string , exception: true) -> Integer | :wait _ writable (113.0) -
IO をノンブロッキングモードに設定し、string を write(2) システムコールで書き出します。
...。
@param exception false を指定すると、書き込み時に Errno::EAGAIN、Errno::EWOULDBLOCK が発生
する代わりに :wait_writable を返します。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX... -
StringIO
# read _ nonblock(maxlen , outbuf = nil , exception: true) -> String | nil (107.0) -
StringIO#readに似ていますが、 exception オプションに false を指定すると EOFError を発生させず nil を返します。
...StringIO#readに似ていますが、 exception オプションに false を指定すると EOFError を発生させず nil を返します。
@param len 読み込みたい長さを整数で指定します。StringIO#read と同じです。
@param outbuf 読み込んだ文字列を出力するバ......込んだデータのサイズになります。IO#read と同じです。
@param exception false を指定した場合、既に EOF に達していれば
EOFError の代わりに nil を返します。
@raise EOFError 文字列の終端に達した場合に発生します。...