1
|
<?php
|
2
|
|
3
|
namespace Illuminate\Database;
|
4
|
|
5
|
use Exception;
|
6
|
use Illuminate\Support\Str;
|
7
|
|
8
|
trait DetectsLostConnections
|
9
|
{
|
10
|
/**
|
11
|
* Determine if the given exception was caused by a lost connection.
|
12
|
*
|
13
|
* @param \Exception $e
|
14
|
* @return bool
|
15
|
*/
|
16
|
protected function causedByLostConnection(Exception $e)
|
17
|
{
|
18
|
$message = $e->getMessage();
|
19
|
|
20
|
return Str::contains($message, [
|
21
|
'server has gone away',
|
22
|
'no connection to the server',
|
23
|
'Lost connection',
|
24
|
'is dead or not enabled',
|
25
|
'Error while sending',
|
26
|
'decryption failed or bad record mac',
|
27
|
'server closed the connection unexpectedly',
|
28
|
'SSL connection has been closed unexpectedly',
|
29
|
'Error writing data to the connection',
|
30
|
'Resource deadlock avoided',
|
31
|
]);
|
32
|
}
|
33
|
}
|