Skip to content

Commit

Permalink
Catch compile errors on checks
Browse files Browse the repository at this point in the history
  • Loading branch information
parijke committed Jun 15, 2024
1 parent c240f9f commit b4bcd83
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Controller/HealthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace OpenConext\MonitorBundle\Controller;

use OpenConext\MonitorBundle\HealthCheck\HealthCheckChain;
use OpenConext\MonitorBundle\Value\HealthReport;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
Expand All @@ -40,8 +41,11 @@ public function __construct(
#[Route('/internal/health', name: 'monitor.internal_health', methods: ['GET'])]
public function __invoke(): JsonResponse
{
$statusResponse = $this->healthChecker->check();

try {
$statusResponse = $this->healthChecker->check();
} catch (\Exception $exception) {
$statusResponse = HealthReport::buildStatusDown($exception->getMessage());
}
return $this->json($statusResponse, $statusResponse->getStatusCode());
}
}

0 comments on commit b4bcd83

Please sign in to comment.