Skip to content

Commit acb68b3

Browse files
authored
Extend the detection of connection lost in the PostgreSQL ExceptionConverter (#7010)
| Q | A |------------- | ----------- | Type | improvement | Fixed issues | #### Summary In some cases I'm getting the following exception: `Doctrine\DBAL\Exception\DriverException #7 An exception occurred while executing a query: SQLSTATE[HY000]: General error: 7 server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. ` I think this exception should be converted to the ConnectionLost exception.
1 parent b37d160 commit acb68b3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Driver/API/PostgreSQL/ExceptionConverter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ public function convert(Exception $exception, ?Query $query): DriverException
7878
return new ConnectionException($exception, $query);
7979
}
8080

81-
if (str_contains($exception->getMessage(), 'terminating connection')) {
81+
if (
82+
str_contains($exception->getMessage(), 'terminating connection')
83+
|| str_contains($exception->getMessage(), 'server closed the connection')
84+
) {
8285
return new ConnectionLost($exception, $query);
8386
}
8487

0 commit comments

Comments
 (0)