{"record":{"id":"1c83833110888fc0","repo":"Seldaek/monolog","slug":"you-must-provide-either-a-swift-message-instance-o","errorCode":null,"errorMessage":"You must provide either a Swift_Message instance or a callable returning it","messagePattern":"You must provide either a Swift_Message instance or a callable returning it","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/MandrillHandler.php","lineNumber":44,"sourceCode":"    protected string $apiKey;\n\n    /**\n     * @phpstan-param (Swift_Message|callable(): Swift_Message) $message\n     *\n     * @param string                 $apiKey  A valid Mandrill API key\n     * @param callable|Swift_Message $message An example message for real messages, only the body will be replaced\n     *\n     * @throws \\InvalidArgumentException if not a Swift Message is set\n     */\n    public function __construct(string $apiKey, callable|Swift_Message $message, int|string|Level $level = Level::Error, bool $bubble = true)\n    {\n        parent::__construct($level, $bubble);\n\n        if (!$message instanceof Swift_Message) {\n            $message = $message();\n        }\n        if (!$message instanceof Swift_Message) {\n            throw new \\InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it');\n        }\n        $this->message = $message;\n        $this->apiKey = $apiKey;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    protected function send(string $content, array $records): void\n    {\n        $mime = 'text/plain';\n        if ($this->isHtmlBody($content)) {\n            $mime = 'text/html';\n        }\n\n        $message = clone $this->message;\n        $message->setBody($content, $mime);\n        /** @phpstan-ignore-next-line */","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/MandrillHandler.php#L26-L62","documentation":"Error \"You must provide either a Swift_Message instance or a callable returning it\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/MandrillHandler.php:44 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"}