ライブラリ
- ビルトイン (116)
- e2mmap (24)
-
rubygems
/ commands / lock _ command (11) -
rubygems
/ security (11) - stringio (11)
クラス
- Exception (62)
- Fiber (5)
-
Gem
:: Commands :: LockCommand (11) -
Gem
:: Security :: Policy (11) - IO (22)
- StringIO (11)
- Thread (16)
- TracePoint (11)
モジュール
キーワード
- Fail (6)
- Raise (6)
- backtrace (11)
-
backtrace
_ locations (11) - cause (11)
- complain (11)
- fail (6)
-
raised
_ exception (11) -
read
_ nonblock (22) -
report
_ on _ exception (8) -
report
_ on _ exception= (8) -
set
_ backtrace (11) -
verify
_ gem (11) -
write
_ nonblock (11)
検索結果
先頭5件
-
Exception
# exception(error _ message) -> Exception (33444.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] (27553.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......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... -
TracePoint
# raised _ exception -> Exception (24627.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
rescue
end
//}... -
Fiber
# raise(exception , message = nil , backtrace = nil) -> object (24441.0) -
selfが表すファイバーが最後に Fiber.yield を呼んだ場所で例外を発生させます。
...さない場合、RuntimeError が発生します。
message 引数を渡した場合、message 引数をメッセージとした RuntimeError
が発生します。
その他のケースでは、最初の引数は Exception か Exception
のインスタンスを返す exception メソッドを持......@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
# backtrace -> [String] (24313.0) -
バックトレース情報を返します。
...line}:in `#{method}'"
(メソッド内の場合)
* "#{sourcefile}:#{sourceline}"
(トップレベルの場合)
という形式の String の配列です。
//emlist[例][ruby]{
def methd
raise
end
begin
methd
rescue => e
p e.backtrace
end
#=> ["filename.rb:2:in `methd'", "filenam......e.rb:6"]
//}
@see Exception#backtrace_locations... -
Exception
# set _ backtrace(errinfo) -> nil | String | [String] (24313.0) -
バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。
...rrinfo を設定し、設定されたバックトレース
情報を返します。
@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
//}... -
Exception
# cause -> Exception | nil (18314.0) -
self の前の例外(self が rescue 節や ensure 節の中で発生した例外の場合、 その前に発生していた元々の例外)を返します。存在しない場合は nil を返し ます。
...ue 節や ensure 節の中で発生した例外の場合、
その前に発生していた元々の例外)を返します。存在しない場合は nil を返し
ます。
//emlist[例][ruby]{
begin
begin
raise "inner"
rescue
raise "outer"
end
rescue
p $! # => #<RuntimeError:......outer>
p $!.cause # => #<RuntimeError: inner>
end
//}... -
Exception
# full _ message(highlight: true , order: :bottom) -> String (18243.0) -
例外の整形された文字列を返します。
...order は 2.5.1 で追加されました。
@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。
@param order :top か :bottom で指定する必要......フォルト値は 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"
$stderr = $std......out
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 で指定する必要... -
Gem
:: Commands :: LockCommand # complain(message) -> () (18213.0) -
指定されたメッセージを表示します。--strict が有効な場合は例外が発生します。
...指定されたメッセージを表示します。--strict が有効な場合は例外が発生します。
@param message 表示するメッセージを指定します。
@raise Gem::Exception コマンドラインオプションに --strict が指定されている場合に発生します。... -
Exception2MessageMapper
# Raise(exception _ class = nil , *rest) -> () (15458.0) -
登録されている情報を使用して、例外を発生させます。
...aram exception_class 例外クラス。
@param rest メッセージに埋め込む値。
@raise Exception2MessageMapper::ErrNotRegisteredException 指定された例外クラスに対応するメッセージが存在しない場合に発生します。
例:
class Foo
extend Exception2Messa......apper
p def_exception :NewExceptionClass, "message...%d, %d and %d" # =>
def foo
Raise NewExceptionClass, 1, 2, 3
end
end
Foo.new().foo() #=> in `Raise': message...1, 2 and 3 (Foo::NewExceptionClass)
# という例外が発生します。
Foo.Ra......ise Foo::NewExceptionClass, 1, 3, 5 #=> in `Raise': message...1, 3 and 5 (Foo::NewExceptionClass)
# という例外が発生します。... -
Exception2MessageMapper
# def _ e2message(exception _ class , message _ format) -> Class (15448.0) -
すでに存在する例外クラス exception_class に、 エラーメッセージ用フォーマット message_format を関連づけます。
...存在する例外クラス exception_class に、
エラーメッセージ用フォーマット message_format を関連づけます。
このフォーマットは Exception2MessageMapper#Raise,
Exception2MessageMapper#Fail で使用します。
@param exception_class メッセージを登録す......る例外クラスを指定します。
@param message_format メッセージのフォーマットを指定します。
Kernel.#sprintf のフォーマット文字列と同じ形式を使用できます。
@return exception_class を返します。...