{"record":{"id":"7c4a6eaacec7c7c6","repo":"Seldaek/monolog","slug":"the-factory-closure-should-return-a-handlerinterfa-7c4a6e","errorCode":null,"errorMessage":"The factory Closure should return a HandlerInterface","messagePattern":"The factory Closure should return a HandlerInterface","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/SamplingHandler.php","lineNumber":86,"sourceCode":"            }\n\n            $this->getHandler($record)->handle($record);\n        }\n\n        return false === $this->bubble;\n    }\n\n    /**\n     * Return the nested handler\n     *\n     * If the handler was provided as a factory, this will trigger the handler's instantiation.\n     */\n    public function getHandler(LogRecord|null $record = null): HandlerInterface\n    {\n        if (!$this->handler instanceof HandlerInterface) {\n            $handler = ($this->handler)($record, $this);\n            if (!$handler instanceof HandlerInterface) {\n                throw new \\RuntimeException(\"The factory Closure should return a HandlerInterface\");\n            }\n            $this->handler = $handler;\n        }\n\n        return $this->handler;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function setFormatter(FormatterInterface $formatter): HandlerInterface\n    {\n        $handler = $this->getHandler();\n        if ($handler instanceof FormattableHandlerInterface) {\n            $handler->setFormatter($formatter);\n\n            return $this;\n        }","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/SamplingHandler.php#L68-L104","documentation":"Error \"The factory Closure should return a HandlerInterface\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/SamplingHandler.php:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57eb1028342134e701e77c617565d51b6e5a2a53","analyzedAt":"2026-08-17T02:36:30.259Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}