Mysql try ... catch
This commit is contained in:
parent
8254360d2f
commit
912577617e
@ -5,6 +5,7 @@ namespace danog\MadelineProto\Db;
|
||||
use Amp\Mysql\ConnectionConfig;
|
||||
use Amp\Mysql\Pool;
|
||||
use Amp\Sql\Common\ConnectionPool;
|
||||
use danog\MadelineProto\Logger;
|
||||
use function Amp\call;
|
||||
use function Amp\Mysql\Pool;
|
||||
use function Amp\Promise\wait;
|
||||
@ -62,6 +63,7 @@ class Mysql
|
||||
private static function createDb(ConnectionConfig $config)
|
||||
{
|
||||
wait(call(static function() use($config) {
|
||||
try {
|
||||
$db = $config->getDatabase();
|
||||
$connection = pool($config->withDatabase(null));
|
||||
yield $connection->query("
|
||||
@ -70,6 +72,9 @@ class Mysql
|
||||
COLLATE 'utf8mb4_general_ci'
|
||||
");
|
||||
$connection->close();
|
||||
} catch (\Throwable $e) {
|
||||
Logger::log($e->getMessage(), Logger::ERROR);
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ class MysqlArray implements DbArray
|
||||
try {
|
||||
$request = yield $this->db->execute($query, $params);
|
||||
} catch (\Throwable $e) {
|
||||
Logger::log($e, Logger::ERROR);
|
||||
Logger::log($e->getMessage(), Logger::ERROR);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user