7件ヒット
[1-7件を表示]
(0.125秒)
ライブラリ
- ビルトイン (7)
クラス
- Exception (6)
- TracePoint (1)
キーワード
- == (1)
- backtrace (1)
-
backtrace
_ locations (1) -
raised
_ exception (1) -
set
_ backtrace (1)
検索結果
先頭5件
-
Exception
# exception(error _ message) -> Exception (105733.0) -
引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー を生成し Exception#message 属性を error_message にして返します。
引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー
を生成し Exception#message 属性を error_message にして返します。
Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。
@param error_message エラーメッセージを表す文字列を指定します。
//emlist[例][ruby]{
begin
# ... # 何か処理
rescue => e
raise e.exception("an error occurs during hogeho... -
Exception
# exception -> self (105433.0) -
引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー を生成し Exception#message 属性を error_message にして返します。
引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー
を生成し Exception#message 属性を error_message にして返します。
Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。
@param error_message エラーメッセージを表す文字列を指定します。
//emlist[例][ruby]{
begin
# ... # 何か処理
rescue => e
raise e.exception("an error occurs during hogeho... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (51214.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
... -
Exception
# ==(other) -> bool (51148.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 D... -
Exception
# backtrace -> [String] (51076.0) -
バックトレース情報を返します。
バックトレース情報を返します。
デフォルトでは
* "#{sourcefile}:#{sourceline}:in `#{method}'"
(メソッド内の場合)
* "#{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... -
Exception
# set _ backtrace(errinfo) -> nil | String | [String] (51058.0) -
バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。
バックトレース情報に 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>'"]
$!.se... -
TracePoint
# raised _ exception -> Exception (42682.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
//}