Skip to content

Commit

Permalink
Boyscout: correct exception messages for type conversion errors
Browse files Browse the repository at this point in the history
No need to show a preferred datetime format when the value is not a datetime
  • Loading branch information
Alex Rothuis committed Jul 28, 2016
1 parent 7e1714a commit bd86705
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bd86705

Please sign in to comment.