Skip to content

Commit b3fb91e

Browse files
committed
Handling incorrect server type
1 parent abc3ad6 commit b3fb91e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/check_server.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ class CheckServer
55

66
class << self
77
def geoserver(type)
8-
check_type(type)
8+
return wrong_type(type) unless %w[public UCB].include? type
9+
910
server_name = type == 'public' ? GEOSERVER_NAME : SECURE_GEOSERVER_NAME
1011
url = host_url(server_name)
1112
geoserver_url = url && "#{url.chomp('/')}/wms?service=WMS&request=GetCapabilities"
1213
OkComputer::Registry.register clr_msg(server_name), GeoDataHealthCheck::HttpHeadCheck.new(geoserver_url)
1314
end
1415

1516
def spatial_server(type)
16-
check_type(type)
17+
return wrong_type(type) unless %w[public UCB].include? type
18+
1719
msg = "#{type} #{SPATIAL_SERVER_NAME}"
1820
url = host_url(SPATIAL_SERVER_NAME)
1921
spatial_url = url && "#{url.chomp('/')}/#{type}/berkeley-status/data.zip"
@@ -28,8 +30,9 @@ def clr_msg(msg)
2830
msg.downcase.strip.gsub(/\s+/, '_')
2931
end
3032

31-
def check_type(type)
32-
raise StandardError, "Incorrect server type #{type}, expect either 'public' or 'UCB'" unless %w[public UCB].include? type
33+
def wrong_type(type)
34+
msg = "Incorrect Geoserver or Spatial server type '#{type}', expect either 'public' or 'UCB"
35+
OkComputer::Registry.register msg, GeoDataHealthCheck::HttpHeadCheck.new(' ')
3336
end
3437
end
3538
end

lib/http_head_check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(url, request_timeout = 5)
1010
# rubocop:enable Lint/MissingSuper
1111

1212
def check
13-
return skip_check unless url
13+
return skip_check if url.strip.empty?
1414

1515
response = HttpClient.request(
1616
:head,

0 commit comments

Comments
 (0)