chg: [internal] Better error handling when fetching sightings

pull/9635/head
Jakub Onderka 2024-03-23 11:30:44 +01:00
parent 317fd056b4
commit 646c58095f
2 changed files with 5 additions and 1 deletions

View File

@ -114,6 +114,10 @@ class HttpSocketResponseExtended extends HttpSocketResponse
*/
public function json()
{
if (strlen($this->body) === 0) {
throw new HttpSocketJsonException('Could not parse empty response as JSON.', $this);
}
try {
return JsonTool::decode($this->body);
} catch (Exception $e) {

View File

@ -1445,7 +1445,7 @@ class Sighting extends AppModel
try {
$sightings = $serverSync->fetchSightingsForEvents($chunk);
} catch (Exception $e) {
$this->logException("Failed to download sightings from {$serverSync->server()['Server']['name']}.", $e);
$this->logException("Failed to download sightings from remote server {$serverSync->server()['Server']['name']}.", $e);
continue;
}