From: Brian Quinion Date: Tue, 6 Nov 2012 13:16:19 +0000 (+0000) Subject: move error messages to consistent 'userError' function and return 400 Bad Request X-Git-Tag: v2.2.0~192 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/e70dfa18fa10ef220799905cde86fae039a2a75d move error messages to consistent 'userError' function and return 400 Bad Request --- diff --git a/lib/lib.php b/lib/lib.php index 8a491818..f34b09b7 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -25,6 +25,19 @@ } + function userError($sError) + { + header('HTTP/1.0 400 Bad Request'); + header('Content-type: text/html; charset=utf-8'); + echo "

Bad Request

"; + echo '

Nominatim has encountered an error with your request.

'; + echo "

Details: ".$sError,"

"; + echo '

If you feel this error is incorrect feel free to report the bug in the OSM bug database. Please include the error message above and the URL you used.

'; + echo "\n\n"; + exit; + + } + function fail($sError, $sUserError = false) { if (!$sUserError) $sUserError = $sError; diff --git a/website/search.php b/website/search.php index 69f6a666..ee7979dc 100755 --- a/website/search.php +++ b/website/search.php @@ -43,9 +43,9 @@ + ($bAsTEXT?1:0) ) > CONST_PolygonOutput_MaximumTypes) { if (CONST_PolygonOutput_MaximumTypes) { - echo "Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option"; + userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option"); } else { - echo "Polygon output is disabled"; + userError("Polygon output is disabled"); } exit; } @@ -191,7 +191,7 @@ $aPoints = explode(',',$_GET['route']); if (sizeof($aPoints) % 2 != 0) { - echo "Uneven number of points"; + userError("Uneven number of points"); exit; } $sViewboxCentreSQL = "ST_SetSRID('LINESTRING("; @@ -351,7 +351,7 @@ $aPhrase = $oDB->getRow("select make_standard_name('".pg_escape_string($sPhrase)."') as string"); if (PEAR::isError($aPhrase)) { - echo "Illegal query string (not an UTF-8 string): ".$sPhrase; + userError("Illegal query string (not an UTF-8 string): ".$sPhrase); if (CONST_Debug) var_dump($aPhrase); exit; }