Improve handling of HTTP errors in search
authorTom Hughes <tom@compton.nu>
Thu, 14 May 2015 08:21:19 +0000 (09:21 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 14 May 2015 08:21:19 +0000 (09:21 +0100)
Fixes #969

app/assets/stylesheets/common.scss
app/controllers/geocoder_controller.rb

index 01f602edb96a16ec42d986601c7f88c4d05bb74d..f48f02e50cd213284eafa427857c5d211bd69c5d 100644 (file)
@@ -978,6 +978,7 @@ header .search_forms,
 
 .search_results_error {
   color: #f00;
+  padding: 10px 20px;
 }
 
 /* Rules for routing */
index a4e1ded860d66916b2b2bbaba63aa7c1b4f59af3..2a3012892d736225d9c0fe86166cf529ae49f990 100644 (file)
@@ -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)