44件ヒット
[1-44件を表示]
(0.101秒)
別のキーワード
ライブラリ
- ビルトイン (32)
-
json
/ add / exception (12)
キーワード
- backtrace (12)
-
set
_ backtrace (12) -
to
_ json (12)
検索結果
先頭4件
-
Exception
# set _ backtrace(errinfo) -> nil | String | [String] (6316.0) -
バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。
...rinfo 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>'"]
$!.set_backtrace(["d......ummy1", "dummy2"])
$!.backtrace # => ["dummy1", "dummy2"]
end
//}... -
Exception
# backtrace -> [String] (6209.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 (203.0) -
例外の整形された文字列を返します。
...例外の整形された文字列を返します。
返される文字列は Ruby が捕捉されなかった例外を標準エラー出力に出力するときと
同じ形式です。
そのため、メソッド呼び出し時に $stderr が変更されておらず、$stderr.tty? が真の場合......値は Exception.to_tty? の返り値と同じです。
@param order :top か :bottom で指定する必要があります。
バックトレースの一番奥がエラーメッセージの上(top)か下(bottom)かを指定します。
デフォルト値は Exception.to_tt......ら :bottom で偽なら :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 `<... -
Exception
# to _ json(*args) -> String (109.0) -
自身を JSON 形式の文字列に変換して返します。
...ds::Hash#to_json に渡されます。
//emlist[例][ruby]{
require "json/add/core"
begin
0/0
rescue => e
e.to_json # => "{\"json_class\":\"ZeroDivisionError\",\"m\":\"divided by 0\",\"b\":[\"/path/to/test.rb:4:in `/'\",\"/path/to/test.rb:4:in `<main>'\"]}"
end
//}
@see JSON::Generator::Gener...