From 8394bf54b9828318d4f7226edbe7764a835379a1 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Wed, 15 Sep 2021 10:46:26 +0200 Subject: [PATCH] Run error_log before sending error mail --- MDErrorReporter.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MDErrorReporter.php b/MDErrorReporter.php index eed645d..7f3045b 100644 --- a/MDErrorReporter.php +++ b/MDErrorReporter.php @@ -222,6 +222,13 @@ final class MDErrorReporter { */ public function sendErrorReport(Throwable $exception, string $recipient, string $addDesc = ""):void { + // First, write the error to the general error log. This should happen first, + // so that it will also work if there is a problem retrieving GPG keys. + + \error_log((string)$exception); + + // Second, a mail is generated and sent. + $subject = \get_class($exception) . ": " . $exception->getCode(); $description = $addDesc; @@ -238,8 +245,6 @@ final class MDErrorReporter { $additionalContextInfo ); - \error_log((string)$exception); - } /**