Merge pull request #2182 from lonvia/change-error-for-details

Return 404 for details when no object is found in database
This commit is contained in:
Sarah Hoffmann 2021-02-23 09:09:35 +01:00 committed by GitHub
commit 68c3862270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -81,11 +81,16 @@ if ($sOsmType && $iOsmId > 0) {
exit; 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; $iPlaceID = (int)$sPlaceId;
if (CONST_Use_US_Tiger_Data) { 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.'); $aPointDetails = $oDB->getRow($sSQL, null, 'Could not get details of place object.');
if (!$aPointDetails) { 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']; $aPointDetails['localname'] = $aPointDetails['localname']?$aPointDetails['localname']:$aPointDetails['housenumber'];

View File

@ -44,7 +44,7 @@ Feature: Object details
Scenario Outline: Details via unknown OSM id Scenario Outline: Details via unknown OSM id
When sending details query for <object> When sending details query for <object>
Then a HTTP 400 is returned Then a HTTP 404 is returned
Examples: Examples:
| object | | object |