1717
1818use Phpfastcache \Config \ConfigurationOption ;
1919use Phpfastcache \Core \Item \ExtendedCacheItemInterface ;
20- use Phpfastcache \Exceptions \{
21- PhpfastcacheDriverCheckException , PhpfastcacheLogicException
22- };
20+ use Phpfastcache \Exceptions \{PhpfastcacheDriverCheckException , PhpfastcacheDriverConnectException , PhpfastcacheLogicException };
2321
2422
2523/**
@@ -61,6 +59,7 @@ trait DriverBaseTrait
6159 * @param ConfigurationOption $config
6260 * @param string $instanceId
6361 * @throws PhpfastcacheDriverCheckException
62+ * @throws PhpfastcacheDriverConnectException
6463 */
6564 public function __construct (ConfigurationOption $ config , $ instanceId )
6665 {
@@ -71,7 +70,17 @@ public function __construct(ConfigurationOption $config, $instanceId)
7170 throw new PhpfastcacheDriverCheckException (\sprintf (self ::DRIVER_CHECK_FAILURE , $ this ->getDriverName ()));
7271 }
7372
74- $ this ->driverConnect ();
73+ try {
74+ $ this ->driverConnect ();
75+ }catch (\Exception $ e ){
76+ throw new PhpfastcacheDriverConnectException (\sprintf (
77+ self ::DRIVER_CONNECT_FAILURE ,
78+ $ this ->getDriverName (),
79+ $ e ->getMessage (),
80+ $ e ->getLine () ?: 'unknown line ' ,
81+ $ e ->getFile () ?: 'unknown file '
82+ ));
83+ }
7584 }
7685
7786 /**
0 commit comments