From: Sarah Hoffmann Date: Thu, 6 May 2021 13:36:54 +0000 (+0200) Subject: correctly catch the exception when import date is missing X-Git-Tag: v4.0.0~90^2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/d8ead78e03f1b94994b83285c0d0ddd7b6765f79?ds=inline;hp=--cc correctly catch the exception when import date is missing --- d8ead78e03f1b94994b83285c0d0ddd7b6765f79 diff --git a/lib-php/Status.php b/lib-php/Status.php index 52abfcd0..4a8f5592 100644 --- a/lib-php/Status.php +++ b/lib-php/Status.php @@ -37,7 +37,7 @@ class Status $iDataDateEpoch = $this->oDB->getOne($sSQL); if ($iDataDateEpoch === false) { - throw Exception('Data date query failed '.$iDataDateEpoch->getMessage(), 705); + throw new Exception('Import date is not available', 705); } return $iDataDateEpoch; diff --git a/lib-php/website/status.php b/lib-php/website/status.php index 7c7eb928..03e56f65 100644 --- a/lib-php/website/status.php +++ b/lib-php/website/status.php @@ -17,6 +17,23 @@ if ($sOutputFormat == 'json') { try { $oStatus = new Nominatim\Status($oDB); $oStatus->status(); + + if ($sOutputFormat == 'json') { + $epoch = $oStatus->dataDate(); + $aResponse = array( + 'status' => 0, + 'message' => 'OK', + 'data_updated' => (new DateTime('@'.$epoch))->format(DateTime::RFC3339), + 'software_version' => CONST_NominatimVersion + ); + $sDatabaseVersion = $oStatus->databaseVersion(); + if ($sDatabaseVersion) { + $aResponse['database_version'] = $sDatabaseVersion; + } + javascript_renderData($aResponse); + } else { + echo 'OK'; + } } catch (Exception $oErr) { if ($sOutputFormat == 'json') { $aResponse = array( @@ -28,25 +45,4 @@ try { header('HTTP/1.0 500 Internal Server Error'); echo 'ERROR: '.$oErr->getMessage(); } - exit; } - - -if ($sOutputFormat == 'json') { - $epoch = $oStatus->dataDate(); - $aResponse = array( - 'status' => 0, - 'message' => 'OK', - 'data_updated' => (new DateTime('@'.$epoch))->format(DateTime::RFC3339), - 'software_version' => CONST_NominatimVersion - ); - $sDatabaseVersion = $oStatus->databaseVersion(); - if ($sDatabaseVersion) { - $aResponse['database_version'] = $sDatabaseVersion; - } - javascript_renderData($aResponse); -} else { - echo 'OK'; -} - -exit;