diff --git a/src/NewsWidget.php b/src/NewsWidget.php index 3f4a9cb..5b995dd 100644 --- a/src/NewsWidget.php +++ b/src/NewsWidget.php @@ -38,6 +38,7 @@ protected function run(array $params = []): ?string $news = $this->getNews(); try { + if (isset($news['information'])) { $currentItem = $news['information']; } else { @@ -51,12 +52,12 @@ protected function run(array $params = []): ?string 'datechanged' => $currentItem['modifiedAt'], 'datefetched' => date('Y-m-d H:i:s'), ]; - } catch (\Throwable $e) { + } catch (\Exception $e) { $context = [ 'type' => 'error', 'title' => 'Unable to fetch news!', 'link' => '', - 'news' => '
Invalid JSON feed returned by ' . $this->source . '
Invalid JSON feed returned by " . $this->source . "
Unable to connect to ' . $this->source . '
' . $message . ' ', + 'content' => "Unable to connect to " . $this->source . "
" . $message . " ", 'link' => null, ], 'modifiedAt' => '0000-01-01 00:00:00', @@ -118,7 +120,7 @@ private function getNews(): array 'type' => 'error', 'fieldValues' => [ 'title' => 'Unable to fetch news!', - 'content' => 'Unable to parse JSON from ' . $this->source . '
', + 'content' => "Unable to parse JSON from " . $this->source . "
", 'link' => null, ], 'modifiedAt' => '0000-01-01 00:00:00',