private static function wrapException(Driver $driver, \Exception $driverEx, $msg) { if ($driverEx instanceof Exception\DriverException) { return $driverEx; } if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof Driver\DriverException) { return $driver->convertException($msg, $driverEx); } return new self($msg, 0, $driverEx); }