ライブラリ
- English (11)
- ビルトイン (264)
- e2mmap (18)
-
json
/ add / exception (11) -
net
/ http (11) - rexml (11)
-
rubygems
/ exceptions (22) - timeout (19)
クラス
- Exception (128)
- Fiber (15)
- SignalException (22)
- Thread (11)
- TracePoint (22)
モジュール
- Exception2MessageMapper (18)
- Kernel (77)
-
Net
:: HTTPExceptions (11) - Timeout (19)
キーワード
-
$ ERROR _ INFO (11) -
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - == (11)
- DependencyRemovalException (11)
- EndOfYAMLException (11)
- Fail (6)
-
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 3
. 0 . 0 (4) - ParseException (11)
- Raise (6)
- Rubyの起動 (3)
- Ruby用語集 (11)
- TracePoint (11)
- backtrace (11)
-
backtrace
_ locations (11) - cause (11)
-
extend
_ object (6) - fail (33)
-
handle
_ interrupt (11) - inspect (11)
- logger (11)
- new (11)
- raise (48)
-
raised
_ exception (11) - response (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 8 . 4 feature (11) -
ruby 1
. 9 feature (11) -
set
_ backtrace (11) - signm (11)
- signo (11)
- timeout (19)
-
to
_ json (11) -
to
_ s (11) - 制御構造 (11)
検索結果
先頭5件
-
Exception
# exception(error _ message) -> Exception (36437.0) -
引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー を生成し Exception#message 属性を error_message にして返します。
...し Exception#message 属性を error_message にして返します。
Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。
@param error_message エラーメッセージを表す文字列を指定します。
//emlist[例][ruby]{
begin
#......... # 何か処理
rescue => e
raise e.exception("an error occurs during hogehoge process") # 詳しいエラーメッセージ
end
//}... -
Exception
# exception -> self (36237.0) -
引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー を生成し Exception#message 属性を error_message にして返します。
...し Exception#message 属性を error_message にして返します。
Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。
@param error_message エラーメッセージを表す文字列を指定します。
//emlist[例][ruby]{
begin
#......... # 何か処理
rescue => e
raise e.exception("an error occurs during hogehoge process") # 詳しいエラーメッセージ
end
//}... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (18264.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...Exception#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if......aise "#{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:i......n `<main>'"]
//}
@see Exception#backtrace... -
Gem
:: DependencyRemovalException (18000.0) -
Gem を削除出来なかった場合に使用する例外です。
Gem を削除出来なかった場合に使用する例外です。 -
Gem
:: EndOfYAMLException (18000.0) -
YAML データが不正である場合に使用する例外です。
YAML データが不正である場合に使用する例外です。 -
Exception
# inspect -> String (15218.0) -
self のクラス名と message を文字列にして返します。
...self のクラス名と message を文字列にして返します。
//emlist[例][ruby]{
begin
raise "exception"
rescue
p $!.inspect # => "#<RuntimeError: exception>"
end
//}... -
TracePoint
# raised _ exception -> Exception (12320.0) -
発生した例外を返します。
...@raise RuntimeError :raise イベントのためのイベントフックの外側で実行し
た場合に発生します。
//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided by 0>
end
trace.enable
begin
0/0
r......escue
end
//}... -
Exception
# set _ backtrace(errinfo) -> nil | String | [String] (12312.0) -
バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。
...ース情報に errinfo を設定し、設定されたバックトレース
情報を返します。
@param errinfo nil、String あるいは String の配列のいずれかを指定します。
//emlist[例][ruby]{
begin
begin
raise "inner"
rescue
raise "outer"
end
rescue
$!.backt......race # => ["/path/to/test.rb:5:in `rescue in <main>'", "/path/to/test.rb:2:in `<main>'"]
$!.set_backtrace(["dummy1", "dummy2"])
$!.backtrace # => ["dummy1", "dummy2"]
end
//}... -
Exception
# full _ message(highlight: true , order: :bottom) -> String (12224.0) -
例外の整形された文字列を返します。
...て実際に、キーワード引数 highlight と order は 2.5.1 で追加されました。
@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。
@......デフォルト値は Exception.to_tty? が真なら :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"
$s......tderr = $stdout
p e.full_message # => "test.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?......シーケンスによる文字装飾がついています。
@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。
@param order :top か :bottom で... -
Exception
# cause -> Exception | nil (12213.0) -
self の前の例外(self が rescue 節や ensure 節の中で発生した例外の場合、 その前に発生していた元々の例外)を返します。存在しない場合は nil を返し ます。
...その前に発生していた元々の例外)を返します。存在しない場合は nil を返し
ます。
//emlist[例][ruby]{
begin
begin
raise "inner"
rescue
raise "outer"
end
rescue
p $! # => #<RuntimeError: outer>
p $!.cause # => #<RuntimeError: inner>
end
//}...