{"record":{"id":"49d34a29dcc36d76","repo":"Seldaek/monolog","slug":"the-factory-closure-should-return-a-handlerinterfa","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/FilterHandler.php","lineNumber":158,"sourceCode":"            }\n        }\n\n        if (\\count($filtered) > 0) {\n            $this->getHandler($filtered[\\count($filtered) - 1])->handleBatch($filtered);\n        }\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":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/FilterHandler.php#L140-L176","documentation":"Error \"The factory Closure should return a HandlerInterface\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/FilterHandler.php:158 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"}