るりまサーチ

最速Rubyリファレンスマニュアル検索!
49件ヒット [1-49件を表示] (0.249秒)
トップページ > クエリ:b[x] > クエリ:_builtin[x] > クエリ:$stderr[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

モジュール

検索結果

Kernel$$stderr -> object (26273.0)

標準エラー出力です。

...標準エラー出力です。

Ruby インタプリタが出力するエラーメッセージや
警告メッセージ、Kernel.#warn の出力先となります。
初期値は Object::STDERR です。

$stderr
に代入するオブジェクトには
write という名前のメソッドが定義...
...力をリダイレクトしたいときには、
$stderr
に代入すれば十分です。

//emlist[例][ruby]{
# 標準エラー出力の出力先を /tmp/foo に変更
$stderr
= File.open("/tmp/foo", "w")
puts "foo" # 出力する
$stderr
= STDERR # 元に戻す
//}

自プロセスだ...
...例][ruby]{
$stderr
.reopen("/tmp/foo", "w")
//}

また、リダイレクトしたあと
出力先をまた元に戻したい場合は以下のようにします。

//emlist[例][ruby]{
stderr_old = $stderr.dup # 元の $stderr を保存する
$stderr
.reopen("/tmp/foo") # $stderr を /t...

Thread#report_on_exception -> bool (8134.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...内容を $stderr に報告します。

デフォルトはスレッド作成時の Thread.report_on_exception です。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。

//emlist[例][ruby]{
a = Threa...
...c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b
= Thread.new{ Thread.stop; raise }
b
.report_on_exception = false
b
.run #...
...=> #<Thread:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...

Thread.report_on_exception -> bool (8122.0)

真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

... $stderr に報告します。

デフォルトは false です。

Thread.new { 1.times { raise } }

$stderr に以下のように出力します:

#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block...
... $stderr に報告します。

デフォルトは true です。

Thread.new { 1.times { raise } }

$stderr に以下のように出力します:

#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block...

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

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

...列を返します。

返される文字列は Ruby が捕捉されなかった例外を標準エラー出力に出力するときと
同じ形式です。
そのため、メソッド呼び出し時に $stderr が変更されておらず、$stderr.tty? が真の場合は
エスケープシーケン...
...:bottom で指定する必要があります。
バックトレースの一番奥がエラーメッセージの上(top)か下(bottom)かを指定します。
デフォルト値は Exception.to_tty? が真なら :bottom で偽なら :top です。

//emlist[例][ruby]{
b
egi...
...ceback \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 `<main>': test (RuntimeError)\n"
$stderr
= STDERR
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:...

Exception.to_tty? -> bool (8116.0)

$stderr が変更されておらず、$stderr.tty? が真の場合は true を返します。

...
$stderr
が変更されておらず、$stderr.tty? が真の場合は true を返します。

[注意] 2.5.1 で追加されたメソッドです。

@see Exception#full_message...
...
$stderr
が変更されておらず、$stderr.tty? が真の場合は true を返します。


@see Exception#full_message...

絞り込み条件を変える

Thread#report_on_exception=(newstate) (8034.0)

真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。

...内容を $stderr に報告します。

デフォルトはスレッド作成時の Thread.report_on_exception です。

@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。

//emlist[例][ruby]{
a = Threa...
...c7908@(irb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b
= Thread.new{ Thread.stop; raise }
b
.report_on_exception = false
b
.run #...
...=> #<Thread:0x00007fc3f48aefc0@(irb):4 dead>
//}

@see Thread.report_on_exception...