Skip to content

Commit

Permalink
Merge pull request #9635 from JakubOnderka/error-handling-sighting
Browse files Browse the repository at this point in the history
chg: [internal] Better error handling when fetching sightings
  • Loading branch information
JakubOnderka committed Mar 23, 2024
2 parents fbaff5d + 646c580 commit 0a77e3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/Lib/Tools/HttpSocketExtended.php
Expand Up @@ -114,6 +114,10 @@ public function parseResponse($message)
*/
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) {
Expand Down
2 changes: 1 addition & 1 deletion app/Model/Sighting.php
Expand Up @@ -1445,7 +1445,7 @@ private function pullSightingNewWay(array $user, array $eventUuids, ServerSyncTo
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;
}

Expand Down

0 comments on commit 0a77e3c

Please sign in to comment.