From: Tom Hughes Date: Thu, 14 May 2015 08:21:19 +0000 (+0100) Subject: Improve handling of HTTP errors in search X-Git-Tag: live~4125 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/b4caac4d4980dab3e0c94a346a0eac0fa64fbb6f?hp=14d4b9206c636adecb0812e60d682416b634af38 Improve handling of HTTP errors in search Fixes #969 --- diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 01f602edb..f48f02e50 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -978,6 +978,7 @@ header .search_forms, .search_results_error { color: #f00; + padding: 10px 20px; } /* Rules for routing */ diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index a4e1ded86..2a3012892 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -286,7 +286,13 @@ class GeocoderController < ApplicationController private def fetch_text(url) - OSM.http_client.get(URI.parse(url)).body + response = OSM.http_client.get(URI.parse(url)) + + if response.success? + response.body + else + fail response.status.to_s + end end def fetch_xml(url)