Bolt\Exception\LowLevelDatabaseException::failedConnect PHP Метод

failedConnect() публичный статический Метод

public static failedConnect ( $platform, Exception $previous )
$previous Exception
    public static function failedConnect($platform, \Exception $previous)
    {
        $error = <<<TEXT
Bolt could not connect to the configured database.

Things to check:
&nbsp;&nbsp;* Ensure the {$platform} database is running
&nbsp;&nbsp;* Check the <code>database:</code> parameters are configured correctly in <code>app/config/config.yml</code>
&nbsp;&nbsp;&nbsp;&nbsp;* Database name is correct
&nbsp;&nbsp;&nbsp;&nbsp;* User name has access to the named database
&nbsp;&nbsp;&nbsp;&nbsp;* Password is correct
TEXT;
        return new static($error, $previous->getCode(), $previous);
    }

Usage Example

Пример #1
0
 /**
  * Event fired on database connection failure.
  *
  * @param FailedConnectionEvent $args
  *
  * @throws LowLevelDatabaseException
  */
 public function failConnect(FailedConnectionEvent $args)
 {
     $e = $args->getException();
     $this->logger->debug($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
     // Trap double exceptions
     set_exception_handler(function () {
     });
     /*
      * Using Driver here since Platform may try to connect
      * to the database, which has failed since we are here.
      */
     $platform = $args->getDriver()->getName();
     $platform = Str::replaceFirst('pdo_', '', $platform);
     throw LowLevelDatabaseException::failedConnect($platform, $e);
 }