Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
snuzi committed Dec 20, 2023
1 parent 11a45b1 commit e4f1e40
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
33 changes: 17 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/BlogRssAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public function run($rssFeed) {
$meiliClient->addDocuments($posts);
printf("%d documents indexed \n", count($posts));

} catch (\Error $t) {
// Executed only in PHP 7, will not match in PHP 5
printf("Failed, message: %s \n", $t->getMessage());
} catch (\Exception $e) {
printf("Failed, message: %s \n", $e->getMessage());
}
Expand Down
4 changes: 4 additions & 0 deletions src/Scraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function scrapePage($url): array {
* @return string
*/
private function getAbsoluteUrl($baseUrl, $imageUrl): string {
if (!$imageUrl) {
return '';
}

if (str_starts_with($imageUrl, 'http')) {
return $imageUrl;
}
Expand Down

0 comments on commit e4f1e40

Please sign in to comment.