るりまサーチ

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

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. rdoc/require require

ライブラリ

クラス

モジュール

検索結果

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

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

...ます。

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

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

uri = "http://www.example.com/index.html"
response
= Net::HTTP.get_response(URI.parse(uri))
response
.value # => nil
//}

//emlist[例 レス...
...ポンスが 2xx以外][ruby]{
require
'net/http'

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

Net::HTTPExceptions#response -> Net::HTTPResponse (21350.0)

例外の原因となったレスポンスオブジェクトを返します。

...レスポンスオブジェクトを返します。

//emlist[例][ruby]{
require
'net/http'

uri = "http://www.example.com/invalid.html"
response
= Net::HTTP.get_response(URI.parse(uri))
begin
response
.value
rescue => e
e.response # => #<Net::HTTPNotFound 404 Not Found readbody=true>
end
//}...