Skip to content

Commit fd12b17

Browse files
committed
fix(insights): catch insights errors
1 parent c1103d3 commit fd12b17

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

packages/console/src/Commands/AboutCommand.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ private function writeFormattedInsights(): void
4949

5050
$this->console->header($provider->name);
5151

52-
foreach ($provider->getInsights() as $key => $value) {
53-
$this->console->keyValue($key, $this->formatInsight($value));
52+
try {
53+
foreach ($provider->getInsights() as $key => $value) {
54+
$this->console->keyValue($key, $this->formatInsight($value));
55+
}
56+
} catch (\Throwable $th) {
57+
$this->console->error('Failed to get insights: ' . $th->getMessage());
5458
}
5559
}
5660
}
@@ -63,10 +67,13 @@ private function writeInsightsAsJson(): void
6367
/** @var InsightsProvider $provider */
6468
$provider = $this->container->get($class);
6569

66-
$json[Str\to_snake_case($provider->name)] = Arr\map_with_keys(
67-
array: $provider->getInsights(),
68-
map: fn (mixed $value, string $key) => yield Str\to_snake_case($key) => $this->rawInsight($value),
69-
);
70+
try {
71+
$json[Str\to_snake_case($provider->name)] = Arr\map_with_keys(
72+
array: $provider->getInsights(),
73+
map: fn (mixed $value, string $key) => yield Str\to_snake_case($key) => $this->rawInsight($value),
74+
);
75+
} catch (\Throwable) {
76+
}
7077
}
7178

7279
$this->console->writeRaw(Json\encode($json));

0 commit comments

Comments
 (0)