lib/pageflow/chart/downloader.rb in pageflow-chart-2.1.0 vs lib/pageflow/chart/downloader.rb in pageflow-chart-2.2.0
- old
+ new
@@ -4,18 +4,21 @@
module Pageflow
module Chart
class Downloader
attr_reader :options
+ class HTTPError < StandardError; end
+
def initialize(options = {})
@options = options
end
- def load(url)
+ def load(url, raise_on_http_error: false)
file = open(make_absolute(url))
yield(file)
rescue OpenURI::HTTPError => exception
Rails.logger.error "Exception loading url #{url}: #{exception.message}"
+ raise(HTTPError) if raise_on_http_error
ensure
file.close if file
end
def load_all(urls, options = {})