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

Custom driver and ExceptionConverter #6317

Closed
gitomato opened this issue Feb 28, 2024 · 1 comment
Closed

Custom driver and ExceptionConverter #6317

gitomato opened this issue Feb 28, 2024 · 1 comment

Comments

@gitomato
Copy link

Feature Request

Q A
New Feature no
RFC no

Summary

When writing a custom driver, at some point we need to implement ExceptionConverter interface.

The convert() method requires to return a DriverException.
However this class is marked as internal and triggers a warning:

The "Doctrine\DBAL\Exception\DriverException::__construct()" method is considered internal. It may change without further notice. You should not extend it from "App\DBAL\Exception\DriverException".

Could you consider returning the Doctrine\DBAL\Driver\Exception interface instead in the future?

PS: thanks for you amazing work!

@derrabus
Copy link
Member

The convert() method requires to return a DriverException. However this class is marked as internal and triggers a warning:

The "Doctrine\DBAL\Exception\DriverException::__construct()" method is considered internal. It may change without further notice. You should not extend it from "App\DBAL\Exception\DriverException".

We should probably not flag the constructor as @internal. I'm open to removing this annotation on 4.1.x because custom drivers need to call that constructor. Please send a PR.

That being said: this might not be the only "internal" API you will need to call for your custom driver. Please keep opening issues if you run into more of them. ✌🏻

Could you consider returning the Doctrine\DBAL\Driver\Exception interface instead in the future?

That's a terrible idea. The whole point of the exception converter is to upcast an exception specific to your database to one of the well-known exceptions that extend DriverException. If the converter returned anything else, the wrapper layer or the application wouldn't know what to do with that exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants