Merge pull request #2314 from lonvia/fix-status-no-import-date

Correctly catch the exception when import date is missing
This commit is contained in:
Sarah Hoffmann 2021-05-06 17:41:53 +02:00 committed by GitHub
commit 40cb17d299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 22 deletions

View File

@ -37,7 +37,7 @@ class Status
$iDataDateEpoch = $this->oDB->getOne($sSQL); $iDataDateEpoch = $this->oDB->getOne($sSQL);
if ($iDataDateEpoch === false) { if ($iDataDateEpoch === false) {
throw Exception('Data date query failed '.$iDataDateEpoch->getMessage(), 705); throw new Exception('Import date is not available', 705);
} }
return $iDataDateEpoch; return $iDataDateEpoch;

View File

@ -17,22 +17,8 @@ if ($sOutputFormat == 'json') {
try { try {
$oStatus = new Nominatim\Status($oDB); $oStatus = new Nominatim\Status($oDB);
$oStatus->status(); $oStatus->status();
} catch (Exception $oErr) {
if ($sOutputFormat == 'json') { if ($sOutputFormat == 'json') {
$aResponse = array(
'status' => $oErr->getCode(),
'message' => $oErr->getMessage()
);
javascript_renderData($aResponse);
} else {
header('HTTP/1.0 500 Internal Server Error');
echo 'ERROR: '.$oErr->getMessage();
}
exit;
}
if ($sOutputFormat == 'json') {
$epoch = $oStatus->dataDate(); $epoch = $oStatus->dataDate();
$aResponse = array( $aResponse = array(
'status' => 0, 'status' => 0,
@ -45,8 +31,18 @@ if ($sOutputFormat == 'json') {
$aResponse['database_version'] = $sDatabaseVersion; $aResponse['database_version'] = $sDatabaseVersion;
} }
javascript_renderData($aResponse); javascript_renderData($aResponse);
} else { } else {
echo 'OK'; echo 'OK';
}
} catch (Exception $oErr) {
if ($sOutputFormat == 'json') {
$aResponse = array(
'status' => $oErr->getCode(),
'message' => $oErr->getMessage()
);
javascript_renderData($aResponse);
} else {
header('HTTP/1.0 500 Internal Server Error');
echo 'ERROR: '.$oErr->getMessage();
}
} }
exit;