From bd867059e71cb610b6e82341e24f2189a473d2a3 Mon Sep 17 00:00:00 2001 From: Alex Rothuis Date: Thu, 28 Jul 2016 14:20:21 +0200 Subject: [PATCH] Boyscout: correct exception messages for type conversion errors No need to show a preferred datetime format when the value is not a datetime --- .../ApiBundle/Doctrine/Type/AuthorityRoleType.php | 5 ++--- .../ApiBundle/Doctrine/Type/CommonNameType.php | 5 ++--- .../Doctrine/Type/ConfigurationContactInformationType.php | 5 ++--- .../ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php | 5 ++--- .../ApiBundle/Doctrine/Type/ConfigurationLocationType.php | 5 ++--- .../ApiBundle/Doctrine/Type/ContactInformationType.php | 5 ++--- .../StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php | 5 ++--- .../ApiBundle/Doctrine/Type/InstitutionType.php | 5 ++--- .../StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php | 5 ++--- .../ApiBundle/Doctrine/Type/LocationType.php | 5 ++--- .../StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php | 5 ++--- .../ApiBundle/Doctrine/Type/RaLocationNameType.php | 5 ++--- .../Doctrine/Type/ShowRaaContactInformationOptionType.php | 5 ++--- .../ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php | 5 ++--- 14 files changed, 28 insertions(+), 42 deletions(-) diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/AuthorityRoleType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/AuthorityRoleType.php index 1740e6ca8..cb04ac9d8 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/AuthorityRoleType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/AuthorityRoleType.php @@ -59,10 +59,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $authorityRole = new AuthorityRole($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/CommonNameType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/CommonNameType.php index dab85982c..9e462c501 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/CommonNameType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/CommonNameType.php @@ -55,10 +55,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $commonName = new CommonName($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationContactInformationType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationContactInformationType.php index 246ff4148..2ba32b6ae 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationContactInformationType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationContactInformationType.php @@ -65,10 +65,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $contactInformation = new ContactInformation($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php index f73f1f6a9..abf0aff55 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php @@ -65,10 +65,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $institution = new Institution($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationLocationType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationLocationType.php index 1d1a5e4d1..d52f5deb1 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationLocationType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationLocationType.php @@ -65,10 +65,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $location = new Location($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ContactInformationType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ContactInformationType.php index bbcea1bba..93842158a 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ContactInformationType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ContactInformationType.php @@ -55,10 +55,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $contactInformation = new ContactInformation($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php index 8f9481244..32cd2381f 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php @@ -55,10 +55,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $email = new Email($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionType.php index 481a2d612..5f7f410f5 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionType.php @@ -55,10 +55,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $institution = new Institution($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php index bbef10025..dd62270a6 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php @@ -55,10 +55,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $locale = new Locale($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocationType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocationType.php index 9b48ecf98..254cbcb68 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocationType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocationType.php @@ -55,10 +55,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $location = new Location($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php index d4dd3904f..c5ff9903d 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php @@ -55,10 +55,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $nameId = new NameId($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RaLocationNameType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RaLocationNameType.php index 3b8ae4485..d06dd6dc4 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RaLocationNameType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RaLocationNameType.php @@ -65,10 +65,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $raLocationName = new RaLocationName($value); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php index ad3f2b873..94556d183 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php @@ -74,10 +74,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) ); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e); diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php index b26e7fd99..6422fc39d 100644 --- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php +++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php @@ -72,10 +72,9 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $useRaLocationsOption = new UseRaLocationsOption($platform->convertFromBoolean($value)); } catch (InvalidArgumentException $e) { // get nice standard message, so we can throw it keeping the exception chain - $doctrineExceptionMessage = ConversionException::conversionFailedFormat( + $doctrineExceptionMessage = ConversionException::conversionFailed( $value, - $this->getName(), - $platform->getDateTimeFormatString() + $this->getName() )->getMessage(); throw new ConversionException($doctrineExceptionMessage, 0, $e);