5件ヒット
[1-5件を表示]
(0.174秒)
ライブラリ
- ビルトイン (4)
-
json
/ add / exception (1)
キーワード
- backtrace (1)
-
backtrace
_ locations (1) -
set
_ backtrace (1) -
to
_ json (1)
検索結果
先頭5件
-
Exception
# set _ backtrace(errinfo) -> nil | String | [String] (37222.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 _ locations -> [Thread :: Backtrace :: Location] (36994.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...バックトレース情報を返します。Exception#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require......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#backtr... -
Exception
# backtrace -> [String] (36958.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
# full _ message(highlight: true , order: :bottom) -> String (19282.0) -
例外の整形された文字列を返します。
...値は Exception.to_tty? の返り値と同じです。
@param order :top か :bottom で指定する必要があります。
バックトレースの一番奥がエラーメッセージの上(top)か下(bottom)かを指定します。
デフォルト値は Exception.to_tt......e[1m)\n\e[m"
$stderr = $stdout
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?... -
Exception
# to _ json(*args) -> String (9376.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...