Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow add previous exception in ConversionException #3222

Merged
merged 1 commit into from
Mar 3, 2020
Merged

Allow add previous exception in ConversionException #3222

merged 1 commit into from
Mar 3, 2020

Conversation

peter-gribanov
Copy link
Contributor

Q A
Type feature
BC Break no
Fixed issues -

Summary

I often use Value Object, and the code of DBAL type looks something like this:

final class MoneyType extends Type
{
    public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if ($value === null || $value instanceof Money) {
            return $value;
        }

        try {
            return new Money($value, new Currency('EUR'));
        } catch (\Exception $e) {
            throw ConversionException::conversionFailed($value, $this->getName());
        }
    }

    // ...

}

In this case, it would be convenient to add the previous exception to ConversionException.

@peter-gribanov peter-gribanov changed the base branch from master to 2.10.x February 3, 2020 12:54
@peter-gribanov peter-gribanov changed the base branch from 2.10.x to 2.10 February 3, 2020 13:24
Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php

greg0ire
greg0ire previously approved these changes Feb 4, 2020
SenseException
SenseException previously approved these changes Feb 4, 2020
@greg0ire greg0ire closed this Feb 29, 2020
@peter-gribanov
Copy link
Contributor Author

@greg0ire sorry, but why did you close this PR?

@greg0ire
Copy link
Member

greg0ire commented Mar 1, 2020

I deleted branch 2.10, and it closed the PR, and I missed the notification, sorry, I'm going to try to fix this.

@greg0ire greg0ire reopened this Mar 1, 2020
@greg0ire greg0ire dismissed stale reviews from SenseException and themself March 1, 2020 19:19

The base branch was changed.

@greg0ire greg0ire changed the base branch from 2.10 to 2.10.x March 1, 2020 19:19
@peter-gribanov
Copy link
Contributor Author

Travis CI no see files in ./tests/travis/ folder.
https://travis-ci.org/doctrine/dbal/builds/657018720

$ bash ./tests/travis/install-mysql-8.0.sh
bash: ./tests/travis/install-mysql-8.0.sh: No such file or directory
$ if [[ "$DB" == "mysql" || "$DB" == "mysqli" || "$DB" == *"mariadb"* ]]; then mysql < tests/travis/create-mysql-schema.sql; fi;
/home/travis/.travis/functions: line 109: tests/travis/create-mysql-schema.sql: No such file or directory

try rebuild

@peter-gribanov peter-gribanov reopened this Mar 2, 2020
@greg0ire greg0ire requested a review from a team March 3, 2020 08:02
@greg0ire greg0ire merged commit 9e880d9 into doctrine:2.10.x Mar 3, 2020
@greg0ire
Copy link
Member

greg0ire commented Mar 3, 2020

Thanks @peter-gribanov

@peter-gribanov peter-gribanov deleted the PreviousConversionException branch March 4, 2020 07:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants