別のキーワード
種類
- インスタンスメソッド (101)
- モジュール関数 (88)
- 文書 (44)
- 特異メソッド (12)
ライブラリ
- ビルトイン (154)
- e2mmap (36)
-
rubygems
/ commands / lock _ command (11)
クラス
- Exception (51)
- Fiber (15)
-
Gem
:: Commands :: LockCommand (11)
モジュール
- Exception2MessageMapper (36)
- Kernel (88)
キーワード
- == (11)
- Fail (12)
-
NEWS for Ruby 2
. 5 . 0 (7) -
NEWS for Ruby 3
. 0 . 0 (4) - abort (22)
- complain (11)
- fail (39)
- inspect (11)
- raise (48)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 4 feature (11) - 制御構造 (11)
検索結果
先頭5件
-
Exception
# exception(error _ message) -> Exception (27482.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 (27282.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
//}... -
Exception2MessageMapper
# Raise(exception _ class = nil , *rest) -> () (21375.0) -
登録されている情報を使用して、例外を発生させます。
...m exception_class 例外クラス。
@param rest メッセージに埋め込む値。
@raise Exception2MessageMapper::ErrNotRegisteredException 指定された例外クラスに対応するメッセージが存在しない場合に発生します。
例:
class Foo
extend Exception2MessageM......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.Raise Foo::......NewExceptionClass, 1, 3, 5 #=> in `Raise': message...1, 3 and 5 (Foo::NewExceptionClass)
# という例外が発生します。... -
Exception2MessageMapper
. Raise(klass = E2MM , exception _ class = nil , *rest) -> () (21321.0) -
登録されている情報を使用して、例外を発生させます。
...@param klass 一階層上となるクラス名を指定します。
@param exception_class 例外クラス。
@param rest メッセージに埋め込む値。
@raise Exception2MessageMapper::ErrNotRegisteredException 指定された例外クラスに対応するメッセージが存在しない... -
Exception
# full _ message(highlight: true , order: :bottom) -> String (15243.0) -
例外の整形された文字列を返します。
...値は Exception.to_tty? の返り値と同じです。
@param order :top か :bottom で指定する必要があります。
バックトレースの一番奥がエラーメッセージの上(top)か下(bottom)かを指定します。
デフォルト値は Exception.to_tt......ら :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 # => "test.rb:2:in `<main>': test (Runtime......Error)\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?... -
Exception2MessageMapper
# def _ e2message(exception _ class , message _ format) -> Class (12471.0) -
すでに存在する例外クラス exception_class に、 エラーメッセージ用フォーマット message_format を関連づけます。
...に存在する例外クラス exception_class に、
エラーメッセージ用フォーマット message_format を関連づけます。
このフォーマットは Exception2MessageMapper#Raise,
Exception2MessageMapper#Fail で使用します。
@param exception_class メッセージを登録......する例外クラスを指定します。
@param message_format メッセージのフォーマットを指定します。
Kernel.#sprintf のフォーマット文字列と同じ形式を使用できます。
@return exception_class を返します。... -
Exception
# ==(other) -> bool (9170.0) -
自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。
...自身と指定された other のクラスが同じであり、
message と backtrace が == メソッドで比較して
等しい場合に true を返します。そうでない場合に false を返します。
@param other 自身と比較したいオブジェクトを指定します。......トを指定した場合は
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......lts = [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, message, backtrace が同一のため... -
Exception
# inspect -> String (9134.0) -
self のクラス名と message を文字列にして返します。
...self のクラス名と message を文字列にして返します。
//emlist[例][ruby]{
begin
raise "exception"
rescue
p $!.inspect # => "#<RuntimeError: exception>"
end
//}... -
Fiber
# raise(exception , message = nil , backtrace = nil) -> object (6460.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
//}... -
Fiber
# raise(message) -> object (6360.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
//}... -
Exception2MessageMapper
# Fail(exception _ class = nil , *rest) -> () (6275.0) -
登録されている情報を使用して、例外を発生させます。
...m exception_class 例外クラス。
@param rest メッセージに埋め込む値。
@raise Exception2MessageMapper::ErrNotRegisteredException 指定された例外クラスに対応するメッセージが存在しない場合に発生します。
例:
class Foo
extend Exception2MessageM......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.Raise Foo::......NewExceptionClass, 1, 3, 5 #=> in `Raise': message...1, 3 and 5 (Foo::NewExceptionClass)
# という例外が発生します。... -
Fiber
# raise -> object (6260.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
//}... -
Exception2MessageMapper
. Fail(klass = E2MM , exception _ class = nil , *rest) -> () (6221.0) -
登録されている情報を使用して、例外を発生させます。
...@param klass 一階層上となるクラス名を指定します。
@param exception_class 例外クラス。
@param rest メッセージに埋め込む値。
@raise Exception2MessageMapper::ErrNotRegisteredException 指定された例外クラスに対応するメッセージが存在しない... -
Exception2MessageMapper
# fail(exception _ class = nil , *rest) -> () (6219.0) -
登録されている情報を使用して、例外を発生させます。
...されている情報を使用して、例外を発生させます。
@param exception_class 例外クラス。
@param rest メッセージに埋め込む値。
@raise Exception2MessageMapper::ErrNotRegisteredException 指定された例外クラスに対応するメッセージが存在しない...