Skip to content

Commit

Permalink
Improve map preview error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgarner committed Jun 25, 2018
1 parent e6ccf91 commit 98883d4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/controllers/map_previews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ def getinfo
base_wms_url = url_param.gsub(/;jsessionid=[a-z0-9]+/i, ';jsessionid=')
response = URI(base_wms_url).read
render xml: Nokogiri::XML(response)
rescue StandardError => _e
render status: :bad_request
rescue StandardError => exception
Raven.capture_exception(exception)
head :bad_request
end

def proxy
url = correct_url(url_param)
response = URI(url).read
render xml: Nokogiri::XML(response)
rescue StandardError => _e
render status: :bad_request
rescue StandardError => exception
Raven.capture_exception(exception)
head :bad_request
end

private
Expand All @@ -51,7 +53,7 @@ def correct_url(url)
args['service'] = 'WMS'

if %w(getcapabilities getfeatureinfo).exclude?(args['request'].downcase)
raise 'Invalid value for "request"'
raise "Invalid request value for #{uri}"
end

uri.query_values = args
Expand Down

0 comments on commit 98883d4

Please sign in to comment.