Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Commit

Permalink
Rescue errors thrown by remote_asset_file
Browse files Browse the repository at this point in the history
  • Loading branch information
charlespwd committed Apr 21, 2021
1 parent e2a3f9f commit 012ba61
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/theme_check.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require "liquid"

require_relative "theme_check/exceptions"
require_relative "theme_check/analyzer"
require_relative "theme_check/check"
require_relative "theme_check/checks_tracking"
Expand Down
32 changes: 32 additions & 0 deletions lib/theme_check/exceptions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true
require "net/http"

TIMEOUT_EXCEPTIONS = [
Net::ReadTimeout,
Net::OpenTimeout,
Net::WriteTimeout,
Errno::ETIMEDOUT,
Timeout::Error,
]

CONNECTION_EXCEPTIONS = [
IOError,
EOFError,
SocketError,
Errno::EINVAL,
Errno::ECONNRESET,
Errno::ECONNABORTED,
Errno::EPIPE,
Errno::ECONNREFUSED,
Errno::EAGAIN,
Errno::EHOSTUNREACH,
Errno::ENETUNREACH,
]

NET_HTTP_EXCEPTIONS = [
Net::HTTPBadResponse,
Net::HTTPHeaderSyntaxError,
Net::ProtocolError,
*TIMEOUT_EXCEPTIONS,
*CONNECTION_EXCEPTIONS,
]
3 changes: 3 additions & 0 deletions lib/theme_check/remote_asset_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def content
end

@content = res.body

rescue OpenSSL::SSL::SSLError, Zlib::StreamError, *NET_HTTP_EXCEPTIONS
@contents = ''
end

def gzipped_size
Expand Down

0 comments on commit 012ba61

Please sign in to comment.