るりまサーチ

最速Rubyリファレンスマニュアル検索!
302件ヒット [201-300件を表示] (0.109秒)

別のキーワード

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

ライブラリ

キーワード

検索結果

<< < 1 2 3 4 > >>

Exception#to_s -> String (3114.0)

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

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

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

Thread::SizedQueue#deq(non_block = false) -> object (3043.0)

キューからひとつ値を取り出します。 キューに push しようと待っているスレッドがあれば、実行を再開させます。

...@param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q...
....push(r)
}

th1.join
# => resource1
# resource2
# resource3
//}

//emlist[例: nonblock = true][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}

begin
th1.jo...
...in
q.pop(true)
r
escue => e
p e
p e.message
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}

@see Thread::Queue#pop...

Thread::SizedQueue#pop(non_block = false) -> object (3043.0)

キューからひとつ値を取り出します。 キューに push しようと待っているスレッドがあれば、実行を再開させます。

...@param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q...
....push(r)
}

th1.join
# => resource1
# resource2
# resource3
//}

//emlist[例: nonblock = true][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}

begin
th1.jo...
...in
q.pop(true)
r
escue => e
p e
p e.message
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}

@see Thread::Queue#pop...

Thread::SizedQueue#shift(non_block = false) -> object (3043.0)

キューからひとつ値を取り出します。 キューに push しようと待っているスレッドがあれば、実行を再開させます。

...@param non_block true を与えると、キューが空の時に例外 ThreadError が発生します。

//emlist[例][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q...
....push(r)
}

th1.join
# => resource1
# resource2
# resource3
//}

//emlist[例: nonblock = true][ruby]{
r
equire 'thread'

q = SizedQueue.new(4)

th1 = Thread.start do
while resource = q.pop
puts resource
end
end

[:resource1, :resource2, :resource3, nil].each{|r|
q.push(r)
}

begin
th1.jo...
...in
q.pop(true)
r
escue => e
p e
p e.message
end

# => resource1
# resource2
# resource3
# => #<ThreadError: queue empty>
# => "queue empty"
//}

@see Thread::Queue#pop...

Net::HTTPResponse#value -> nil (3019.0)

レスポンスが 2xx(成功)でなかった場合に、対応する 例外を発生させます。

...させます。

@raise HTTPError レスポンスが 1xx であるか、 net/http が知らない
種類のレスポンスである場合に発生します。
@raise HTTPRetriableError レスポンスが 3xx である場合に発生します。
@raise HTTPServerException レスポ...
...合に発生します。
@raise HTTPFatalError レスポンスが 5xx である場合に発生します。

//emlist[例 レスポンスが 2xx(成功)][ruby]{
r
equire 'net/http'

uri = "http://www.example.com/index.html"
r
esponse = Net::HTTP.get_response(URI.parse(uri))
r
esponse.value # => nil
//}...
...//emlist[例 レスポンスが 2xx以外][ruby]{
r
equire 'net/http'

uri = "http://www.example.com/invalid.html"
r
esponse = Net::HTTP.get_response(URI.parse(uri))
begin
r
esponse.value
r
escue => e
e.class # => Net::HTTPServerException
e.message # => 404 "Not Found"
end
//}...

絞り込み条件を変える

Exception#exception(error_message) -> Exception (246.0)

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

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

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

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

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

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

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

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

@param other 自身と比較したいオブジェクトを指定します。...
...[例][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
e
end
end

r
esults = [2, 2, 4].map { |e | get_exception { check_long_month(e) } }
p results...
...[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 が同一のため true になる
p results[0] == results[1] # => true

# class, backtrace が同一だが、message...

Exception#inspect -> String (123.0)

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

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

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

SignalException#signm -> String (123.0)

self.message のエイリアスです。

...self.message のエイリアスです。

//emlist[例][ruby]{
begin
Process.kill('HUP', Process.pid)
sleep
r
escue SignalException => e
puts e.signm # => SIGHUP
end
//}...
<< < 1 2 3 4 > >>