return 404 for details when no bject is found in database

Fixes #2157.
This commit is contained in:
Sarah Hoffmann
2021-02-22 16:28:29 +01:00
parent 72b01148d2
commit 5b7483ada5
2 changed files with 10 additions and 5 deletions

View File

@@ -81,11 +81,16 @@ if ($sOsmType && $iOsmId > 0) {
exit;
}
}
if ($sPlaceId === false) {
throw new Exception('No place with that OSM ID found.', 404);
}
} else {
if ($sPlaceId === false) {
userError('Required parameters missing. Need either osmtype/osmid or place_id.');
}
}
if ($sPlaceId === false) userError('Please select a place id');
$iPlaceID = (int)$sPlaceId;
if (CONST_Use_US_Tiger_Data) {
@@ -140,7 +145,7 @@ $sSQL .= " WHERE place_id = $iPlaceID";
$aPointDetails = $oDB->getRow($sSQL, null, 'Could not get details of place object.');
if (!$aPointDetails) {
userError('Unknown place id.');
throw new Exception('No place with that place ID found.', 404);
}
$aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];