Seldaek/monolog · error · RuntimeException
The factory Closure should return a HandlerInterface
Error message
The factory Closure should return a HandlerInterface
What it means
Error "The factory Closure should return a HandlerInterface" thrown in Seldaek/monolog.
Source
Thrown at src/Monolog/Handler/SamplingHandler.php:86
}
$this->getHandler($record)->handle($record);
}
return false === $this->bubble;
}
/**
* Return the nested handler
*
* If the handler was provided as a factory, this will trigger the handler's instantiation.
*/
public function getHandler(LogRecord|null $record = null): HandlerInterface
{
if (!$this->handler instanceof HandlerInterface) {
$handler = ($this->handler)($record, $this);
if (!$handler instanceof HandlerInterface) {
throw new \RuntimeException("The factory Closure should return a HandlerInterface");
}
$this->handler = $handler;
}
return $this->handler;
}
/**
* @inheritDoc
*/
public function setFormatter(FormatterInterface $formatter): HandlerInterface
{
$handler = $this->getHandler();
if ($handler instanceof FormattableHandlerInterface) {
$handler->setFormatter($formatter);
return $this;
}View on GitHub (pinned to 57eb102834)
When it happens
Trigger: Thrown at src/Monolog/Handler/SamplingHandler.php:86 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Seldaek/monolog@57eb102834 (2026-08-17).
Data as JSON: /api/errors/7c4a6eaacec7c7c6.
Report an issue: GitHub.