mirror of
https://github.com/sdsykes/fastimage.git
synced 2025-09-20 00:01:59 -04:00
Merge pull request #107 from yahorzhylinski/handler-netunreach-exception
Handle `Errno::ENETUNREACH` exception
This commit is contained in:
commit
2132a8f99d
@ -214,7 +214,8 @@ class FastImage
|
||||
raise SizeNotFound if @options[:raise_on_failure] && @property == :size && !@size
|
||||
|
||||
rescue Timeout::Error, SocketError, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET,
|
||||
ImageFetchFailure, Net::HTTPBadResponse, EOFError, Errno::ENOENT, OpenSSL::SSL::SSLError
|
||||
Errno::ENETUNREACH, ImageFetchFailure, Net::HTTPBadResponse, EOFError, Errno::ENOENT,
|
||||
OpenSSL::SSL::SSLError
|
||||
raise ImageFetchFailure if @options[:raise_on_failure]
|
||||
rescue NoMethodError # 1.8.7p248 can raise this due to a net/http bug
|
||||
raise ImageFetchFailure if @options[:raise_on_failure]
|
||||
|
10
test/test.rb
10
test/test.rb
@ -140,6 +140,14 @@ class FastImageTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_raise_image_fetch_failure_error_if_net_unreach_exception_happens
|
||||
FakeWeb.register_uri(:get, "http://example.com", :exception => Errno::ENETUNREACH)
|
||||
|
||||
assert_raises(FastImage::ImageFetchFailure) do
|
||||
FastImage.size("http://example.com", :raise_on_failure=>true)
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_raise_unknown_image_typ_when_file_is_non_svg_xml
|
||||
assert_raises(FastImage::UnknownImageType) do
|
||||
FastImage.size(TestUrl + "test.xml", :raise_on_failure=>true)
|
||||
@ -429,7 +437,7 @@ class FastImageTest < Test::Unit::TestCase
|
||||
def test_should_return_content_length_for_data_uri_images
|
||||
assert_equal DataUriImageContentLength, FastImage.new(DataUriImage).content_length
|
||||
end
|
||||
|
||||
|
||||
def test_canon_raw_formats_are_not_recognised_as_tiff
|
||||
assert_raises(FastImage::UnknownImageType) do
|
||||
FastImage.size(TestUrl + "a.CR2", :raise_on_failure=>true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user