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

throw DBALException replace throw Exception #4062

Conversation

295black
Copy link

Q A
Type bug
BC Break yes
Fixed issues

Summary

When i use the function ping() in MasterSlaveConnection, can not catch the Exception. Because in the class Doctrine\DBAL\Connection, the function ping only can catch DBALException.However the function query() in MasterSlaveConnection not throw it.

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2020

Codecov Report

Merging #4062 into 2.10.x will decrease coverage by 0.01%.
The diff coverage is 33.33%.

Impacted file tree graph

@@             Coverage Diff              @@
##             2.10.x    #4062      +/-   ##
============================================
- Coverage     73.32%   73.31%   -0.02%     
- Complexity     5031     5032       +1     
============================================
  Files           215      215              
  Lines         12825    12827       +2     
============================================
  Hits           9404     9404              
- Misses         3421     3423       +2     
Impacted Files Coverage Δ Complexity Δ
...octrine/DBAL/Connections/MasterSlaveConnection.php 65.76% <33.33%> (-1.21%) 43.00 <0.00> (+1.00) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ad4c16...622c79c. Read the comment docs.

try {
$statement = $this->_conn->query(...$args);
} catch (Throwable $ex) {
throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $args[0]);
Copy link
Member

Choose a reason for hiding this comment

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

Although this is correct, this is a breaking change and should be retargeted against 3.0.x.

$statement = $this->_conn->query(...$args);
try {
$statement = $this->_conn->query(...$args);
} catch (Throwable $ex) {
Copy link
Member

Choose a reason for hiding this comment

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

A driver-level connection should be expected to only throw a DriverException (see #4072).

@morozov morozov changed the base branch from 2.10.x to 2.12.x November 29, 2020 21:35
@morozov morozov closed this Apr 21, 2021
@morozov morozov deleted the branch doctrine:2.12.x April 21, 2021 16:26
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants