From c6b9dd4f368c71424521211f0fbf4e8721d15308 Mon Sep 17 00:00:00 2001 From: Martin Adler Date: Fri, 13 Sep 2024 17:45:02 +0200 Subject: [PATCH] [BUGFIX] Throw exception for invalid options --- Classes/Config/LogLevel.php | 5 +++++ Classes/Exception/InvalidLogWriterOptionException.php | 2 +- Classes/Writer/StreamWriter.php | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Classes/Config/LogLevel.php b/Classes/Config/LogLevel.php index cd63b76..8c0d408 100644 --- a/Classes/Config/LogLevel.php +++ b/Classes/Config/LogLevel.php @@ -24,6 +24,11 @@ namespace mteu\StreamWriter\Config; /** + * LogLevel. + * + * @author Martin Adler + * @license GPL-3.0-or-later + * * @codeCoverageIgnore */ enum LogLevel: string diff --git a/Classes/Exception/InvalidLogWriterOptionException.php b/Classes/Exception/InvalidLogWriterOptionException.php index f359396..a2565b9 100644 --- a/Classes/Exception/InvalidLogWriterOptionException.php +++ b/Classes/Exception/InvalidLogWriterOptionException.php @@ -24,7 +24,7 @@ namespace mteu\StreamWriter\Exception; /** - * InvalidOptionException. + * InvalidLogWriterOptionException. * * @author Martin Adler * @license GPL-3.0-or-later diff --git a/Classes/Writer/StreamWriter.php b/Classes/Writer/StreamWriter.php index e218a70..5c82154 100644 --- a/Classes/Writer/StreamWriter.php +++ b/Classes/Writer/StreamWriter.php @@ -26,6 +26,7 @@ use mteu\StreamWriter\Config\LogLevel; use mteu\StreamWriter\Config\StandardStream; use mteu\StreamWriter\Exception\InvalidLogWriterConfigurationException; +use mteu\StreamWriter\Exception\InvalidLogWriterOptionException; use TYPO3\CMS\Core\Log\LogRecord; use TYPO3\CMS\Core\Log\Writer\AbstractWriter; use TYPO3\CMS\Core\Log\Writer\WriterInterface; @@ -57,7 +58,7 @@ final class StreamWriter extends AbstractWriter /** * @param array{outputStream: StandardStream} $options - * @throws InvalidLogWriterConfigurationException + * @throws InvalidLogWriterConfigurationException|\TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException */ public function __construct(array $options = ['outputStream' => StandardStream::Error]) { @@ -70,7 +71,7 @@ public function __construct(array $options = ['outputStream' => StandardStream:: /** * @return LogLevel|StandardStream|class-string[] - * @throws InvalidLogWriterConfigurationException + * @throws InvalidLogWriterOptionException */ public function getOption(string $option): array|LogLevel|StandardStream { @@ -78,7 +79,7 @@ public function getOption(string $option): array|LogLevel|StandardStream 'outputStream' => $this->outputStream, 'maxLevel' => $this->maxLevel, 'ignoredComponents' => $this->ignoredComponents, - default => throw new InvalidLogWriterConfigurationException( + default => throw new InvalidLogWriterOptionException( 'Option ' . $option . ' does not exist.', 1726173519 ),