benecaster_health_check_failed
Fires when a health check’s evaluate() throws instead of completing. Benecaster catches the exception, so one broken check can’t break the admin page or stop the checks after it, and records it in the Debug Log at error level. That log reaches the site owner and Benecaster support, not the add-on that registered the check. This hook is how your add-on hears that its own check failed.
A failed check has done nothing, and that is ambiguous. evaluate() both raises and clears its notice, so a check that threw may have missed a problem it should have reported, or left up a warning it should have cleared. The hook can’t tell you which. If that matters, have evaluate() catch its own errors and decide.
Every check on the install fires this hook, Benecaster’s own included, so match on your own class with instanceof. It fires once per failed run: the admin sweep runs at most once an hour, and the daily license cron runs some checks independently.
Keep the listener cheap and never let it throw. It runs inside Benecaster’s catch block, on an admin page load or the daily cron, and an exception from it escapes the guard that exists to contain this one. The Debug Log entry is written before the hook fires, so a failing listener doesn’t lose it.
Benecaster shows no admin notice for failed checks, because the podcaster could do nothing about one.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$check |
\Benecaster\Notices\HealthChecks\HealthCheck |
— | The check that threw. |
$e |
\Throwable |
— | What it threw. |
Examples
Report your own check's failures to your error tracker
add_action( 'benecaster_health_check_failed', function ( $check, $e ): void {
if ( ! $check instanceof \MyAddon\Notices\HealthChecks\MyApiCheck ) {
return; // Every check on the install fires this hook. Match your own.
}
my_addon_report_to_sentry( $e );
}, 10, 2 );
Need this built rather than just documented? See our services →