Skip to content

Commit efcb68f

Browse files
authored
Merge pull request #23 from OpenConext/feature/monitor-compile-failing-checks
Catch instantiation errors on checks
2 parents c240f9f + 64fc64a commit efcb68f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Controller/HealthController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
namespace OpenConext\MonitorBundle\Controller;
2020

2121
use OpenConext\MonitorBundle\HealthCheck\HealthCheckChain;
22+
use OpenConext\MonitorBundle\Value\HealthReport;
2223
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2324
use Symfony\Component\HttpFoundation\JsonResponse;
2425
use Symfony\Component\Routing\Attribute\Route;
26+
use Throwable;
2527

2628
/**
2729
* Display the health state of the application.
@@ -40,8 +42,11 @@ public function __construct(
4042
#[Route('/internal/health', name: 'monitor.internal_health', methods: ['GET'])]
4143
public function __invoke(): JsonResponse
4244
{
43-
$statusResponse = $this->healthChecker->check();
44-
45+
try {
46+
$statusResponse = $this->healthChecker->check();
47+
} catch (Throwable $exception) {
48+
$statusResponse = HealthReport::buildStatusDown($exception->getMessage());
49+
}
4550
return $this->json($statusResponse, $statusResponse->getStatusCode());
4651
}
4752
}

0 commit comments

Comments
 (0)