mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-07 02:24:08 +00:00
move error messages to consistent 'userError' function and return 400 Bad Request
This commit is contained in:
13
lib/lib.php
13
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 "<html><body><h1>Bad Request</h1>";
|
||||||
|
echo '<p>Nominatim has encountered an error with your request.</p>';
|
||||||
|
echo "<p><b>Details:</b> ".$sError,"</p>";
|
||||||
|
echo '<p>If you feel this error is incorrect feel free to report the bug in the <a href="http://trac.openstreetmap.org">OSM bug database</a>. Please include the error message above and the URL you used.</p>';
|
||||||
|
echo "\n</body></html>\n";
|
||||||
|
exit;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function fail($sError, $sUserError = false)
|
function fail($sError, $sUserError = false)
|
||||||
{
|
{
|
||||||
if (!$sUserError) $sUserError = $sError;
|
if (!$sUserError) $sUserError = $sError;
|
||||||
|
|||||||
@@ -43,9 +43,9 @@
|
|||||||
+ ($bAsTEXT?1:0)
|
+ ($bAsTEXT?1:0)
|
||||||
) > CONST_PolygonOutput_MaximumTypes) {
|
) > CONST_PolygonOutput_MaximumTypes) {
|
||||||
if (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 {
|
} else {
|
||||||
echo "Polygon output is disabled";
|
userError("Polygon output is disabled");
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@
|
|||||||
$aPoints = explode(',',$_GET['route']);
|
$aPoints = explode(',',$_GET['route']);
|
||||||
if (sizeof($aPoints) % 2 != 0)
|
if (sizeof($aPoints) % 2 != 0)
|
||||||
{
|
{
|
||||||
echo "Uneven number of points";
|
userError("Uneven number of points");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$sViewboxCentreSQL = "ST_SetSRID('LINESTRING(";
|
$sViewboxCentreSQL = "ST_SetSRID('LINESTRING(";
|
||||||
@@ -351,7 +351,7 @@
|
|||||||
$aPhrase = $oDB->getRow("select make_standard_name('".pg_escape_string($sPhrase)."') as string");
|
$aPhrase = $oDB->getRow("select make_standard_name('".pg_escape_string($sPhrase)."') as string");
|
||||||
if (PEAR::isError($aPhrase))
|
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);
|
if (CONST_Debug) var_dump($aPhrase);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user