mirror of
https://github.com/danog/postgres.git
synced 2024-12-11 17:09:47 +01:00
Improve error message
This commit is contained in:
parent
31b739bc77
commit
b056da210d
@ -21,7 +21,7 @@ final class ConnectionConfig extends SqlConnectionConfig
|
|||||||
|
|
||||||
return new self(
|
return new self(
|
||||||
$parts["host"],
|
$parts["host"],
|
||||||
$parts["port"] ?? self::DEFAULT_PORT,
|
(int) ($parts["port"] ?? self::DEFAULT_PORT),
|
||||||
$parts["user"] ?? null,
|
$parts["user"] ?? null,
|
||||||
$parts["password"] ?? null,
|
$parts["password"] ?? null,
|
||||||
$parts["db"] ?? null
|
$parts["db"] ?? null
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Amp\Postgres;
|
namespace Amp\Postgres;
|
||||||
|
|
||||||
use Amp\Promise;
|
use Amp\Promise;
|
||||||
use Amp\Sql\ConnectionConfig;
|
use Amp\Sql\ConnectionConfig as SqlConnectionConfig;
|
||||||
use Amp\Sql\Connector;
|
use Amp\Sql\Connector;
|
||||||
use Amp\Sql\FailureException;
|
use Amp\Sql\FailureException;
|
||||||
use Amp\TimeoutCancellationToken;
|
use Amp\TimeoutCancellationToken;
|
||||||
@ -30,8 +30,12 @@ final class TimeoutConnector implements Connector
|
|||||||
*
|
*
|
||||||
* @throws \Error If neither ext-pgsql or pecl-pq is loaded.
|
* @throws \Error If neither ext-pgsql or pecl-pq is loaded.
|
||||||
*/
|
*/
|
||||||
public function connect(ConnectionConfig $connectionConfig): Promise
|
public function connect(SqlConnectionConfig $connectionConfig): Promise
|
||||||
{
|
{
|
||||||
|
if (!$connectionConfig instanceof ConnectionConfig) {
|
||||||
|
throw new \TypeError(\sprintf("Must provide an instance of %s to Postgres connectors", ConnectionConfig::class));
|
||||||
|
}
|
||||||
|
|
||||||
$token = new TimeoutCancellationToken($this->timeout);
|
$token = new TimeoutCancellationToken($this->timeout);
|
||||||
|
|
||||||
if (\extension_loaded("pq")) {
|
if (\extension_loaded("pq")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user