From 412e1d03effa3cc292ce792ed7b9bf38d2168e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Wed, 11 Oct 2023 18:39:44 +0200 Subject: [PATCH] Improved exception message for a non-unique language code --- src/lib/Repository/LanguageService.php | 5 ++++- tests/integration/Core/Repository/LanguageServiceTest.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/Repository/LanguageService.php b/src/lib/Repository/LanguageService.php index 2d6857e5e8..8e47d8ab2b 100644 --- a/src/lib/Repository/LanguageService.php +++ b/src/lib/Repository/LanguageService.php @@ -90,7 +90,10 @@ public function createLanguage(LanguageCreateStruct $languageCreateStruct): Lang try { if ($this->loadLanguage($languageCreateStruct->languageCode) !== null) { - throw new InvalidArgumentException('languageCreateStruct', 'language with the specified language code already exists'); + throw new InvalidArgumentException( + 'languageCreateStruct', + sprintf('language with the "%s" language code already exists', $languageCreateStruct->languageCode) + ); } } catch (APINotFoundException $e) { // Do nothing diff --git a/tests/integration/Core/Repository/LanguageServiceTest.php b/tests/integration/Core/Repository/LanguageServiceTest.php index 5aec2ac61d..a0698f4682 100644 --- a/tests/integration/Core/Repository/LanguageServiceTest.php +++ b/tests/integration/Core/Repository/LanguageServiceTest.php @@ -128,7 +128,7 @@ public function testCreateLanguageSetsExpectedProperties($language) public function testCreateLanguageThrowsInvalidArgumentException() { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Argument \'languageCreateStruct\' is invalid: language with the specified language code already exists'); + $this->expectExceptionMessage('Argument \'languageCreateStruct\' is invalid: language with the "nor-NO" language code already exists'); $repository = $this->getRepository();