Skip to content

Commit a1b4b37

Browse files
committed
log stargazer error
1 parent 4948a92 commit a1b4b37

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/GitHub/GetStargazersCount.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,25 @@ final class GetStargazersCount
1212
public function __construct(
1313
private HttpClient $httpClient,
1414
private Cache $cache,
15-
) {}
15+
) {
16+
}
1617

1718
public function __invoke(): ?string
1819
{
1920
return $this->cache->resolve(
2021
key: 'tempest-stargazers',
2122
cache: function () {
22-
$body = $this->httpClient->get('https://api.github.com/repos/tempestphp/tempest-framework')->body;
23-
$stargazers = json_decode($body)->stargazers_count ?? null;
23+
try {
24+
$body = $this->httpClient->get('https://api.github.com/repos/tempestphp/tempest-framework')->body;
25+
$stargazers = json_decode($body)->stargazers_count ?? null;
2426

25-
return $stargazers > 999
26-
? (round($stargazers / 1000, 1) . 'K')
27-
: $stargazers;
27+
return $stargazers > 999
28+
? (round($stargazers / 1000, 1) . 'K')
29+
: $stargazers;
30+
} catch (Throwable $e) {
31+
ll($e);
32+
return null;
33+
}
2834
},
2935
expiresAt: new DateTimeImmutable('+12 hours'),
3036
);

0 commit comments

Comments
 (0)