るりまサーチ

最速Rubyリファレンスマニュアル検索!
152件ヒット [1-100件を表示] (0.123秒)
トップページ > クエリ:r[x] > クラス:Exception[x]

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. fileutils cp_r

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Exception#backtrace_locations -> [Thread::Backtrace::Location] (6201.0)

バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。

...Exception#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。

現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。

//emlist[例: test.rb][ruby]{
r
equire "date"
def check_long_month(month)
r
eturn if...
...1
r
aise "#{month} is not long month"
end

def get_exception
r
eturn begin
yield
r
escue => 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#backtrace -> [String] (6101.0)

バックトレース情報を返します。

...{sourcefile}:#{sourceline}:in `#{method}'"
(メソッド内の場合)
* "#{sourcefile}:#{sourceline}"
(トップレベルの場合)

という形式の String の配列です。

//emlist[例][ruby]{
def methd
r
aise
end

begin
methd
r
escue => e
p e.backtrace
end

#=> ["filename.rb:2:...
...in `methd'", "filename.rb:6"]
//}

@see Exception#backtrace_locations...

Exception#set_backtrace(errinfo) -> nil | String | [String] (6101.0)

バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。

...報に errinfo を設定し、設定されたバックトレース
情報を返します。

@param errinfo nil、String あるいは String の配列のいずれかを指定します。

//emlist[例][ruby]{
begin
begin
r
aise "inner"
r
escue
r
aise "outer"
end
r
escue
$!.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.json_create(hash) -> Exception (6101.0)

JSON のオブジェクトから Ruby のオブジェクトを生成して返します。

...JSON のオブジェクトから Ruby のオブジェクトを生成して返します。

@param hash 適切なキーを持つハッシュを指定します。...

Exception#==(other) -> bool (101.0)

自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して 等しい場合に true を返します。そうでない場合に false を返します。

...自身と指定された other のクラスが同じであり、
message と backtrace が == メソッドで比較して
等しい場合に true を返します。そうでない場合に false を返します。

@param other 自身と比較したいオブジェクトを指定します。...
...た場合は
Exception
#exception を実行して変換を試みます。

//emlist[例][ruby]{
r
equire "date"
def check_long_month(month)
r
eturn if Date.new(2000, month, -1).day == 31
r
aise "#{month} is not long month"
end

def get_exception
r
eturn begin
yield
r
escue => e...
...end
end

r
esults = [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#exception(error_message) -> Exception (101.0)

引数を指定しない場合は self を返します。引数を指定した場合 自身のコピー を生成し Exception#message 属性を error_message にして返します。

...生成し Exception#message 属性を error_message にして返します。

Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。

@param error_message エラーメッセージを表す文字列を指定します。

//emlist[例][ruby]{
begi...
...n
# ... # 何か処理
r
escue => e
r
aise e.exception("an error occurs during hogehoge process") # 詳しいエラーメッセージ
end
//}...

Exception#full_message(highlight: true, order: :bottom) -> String (101.0)

例外の整形された文字列を返します。

...字列を返します。

返される文字列は Ruby が捕捉されなかった例外を標準エラー出力に出力するときと
同じ形式です。
そのため、メソッド呼び出し時に $stderr が変更されておらず、$stderr.tty? が真の場合は
エスケープシーケ...
...数 highlight と order は 2.5.1 で追加されました。

@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。

@param order :top か :bottom で...
...ルト値は Exception.to_tty? が真なら :bottom で偽なら :top です。

//emlist[例][ruby]{
begin
r
aise "test"
r
escue => 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...
...文字装飾がついています。


@param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。

@param order :top か :bottom で指定する必要があ...

Exception#inspect -> String (101.0)

self のクラス名と message を文字列にして返します。

...self のクラス名と message を文字列にして返します。

//emlist[例][ruby]{
begin
r
aise "exception"
r
escue
p $!.inspect # => "#<RuntimeError: exception>"
end
//}...

Exception#message -> String (101.0)

エラーメッセージをあらわす文字列を返します。

...エラーメッセージをあらわす文字列を返します。

//emlist[例][ruby]{
begin
1 + nil
r
escue => e
p e.message #=> "nil can't be coerced into Fixnum"
end
//}...
<< 1 2 > >>