るりまサーチ (Ruby 2.2.0)

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.038秒)
トップページ > クラス:Exception[x] > バージョン:2.2.0[x] > クエリ:String[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. string []=
  2. string []
  3. string slice
  4. string slice!
  5. string gsub

ライブラリ

キーワード

検索結果

Exception#set_backtrace(errinfo) -> nil | String | [String] (649.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...

Exception#backtrace -> [String] (328.0)

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

...)
* "#{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"]
//}

@see Exception#backtrace_locations...

Exception#message -> String (313.0)

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

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

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

Exception#to_s -> String (313.0)

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

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

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

Exception#inspect -> String (310.0)

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

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

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

絞り込み条件を変える

Exception#to_json(*args) -> String (310.0)

自身を JSON 形式の文字列に変換して返します。

自身を JSON 形式の文字列に変換して返します。

内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡されます。

//emlist[例][ruby]{
require "json/add/core"

begin
0/0
rescue => e
e.to_json # => "{\"json_class\":\"ZeroDivis...