From b4caac4d4980dab3e0c94a346a0eac0fa64fbb6f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 14 May 2015 09:21:19 +0100 Subject: [PATCH 1/1] Improve handling of HTTP errors in search Fixes #969 --- app/assets/stylesheets/common.scss | 1 + app/controllers/geocoder_controller.rb | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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) -- 2.43.2