mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-14 05:06:37 +00:00
Improve clarity of the error that happens when MariaDB fails to boot.
This commit is contained in:
parent
4096c9d2a5
commit
fe4849521f
|
@ -6,7 +6,6 @@
|
|||
|
||||
use App\Environment;
|
||||
use App\Event;
|
||||
use App\Exception;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
return [
|
||||
|
@ -102,7 +101,6 @@ return [
|
|||
]
|
||||
);
|
||||
|
||||
try {
|
||||
$mappingClassesPaths = [$environment->getBaseDirectory() . '/src/Entity'];
|
||||
|
||||
$buildDoctrineMappingPathsEvent = new Event\BuildDoctrineMappingPaths(
|
||||
|
@ -140,17 +138,8 @@ return [
|
|||
$eventManager->addEventSubscriber($eventChangeTracking);
|
||||
|
||||
return new App\Doctrine\DecoratedEntityManager(
|
||||
function () use (
|
||||
$connectionOptions,
|
||||
$config,
|
||||
$eventManager
|
||||
) {
|
||||
return Doctrine\ORM\EntityManager::create($connectionOptions, $config, $eventManager);
|
||||
}
|
||||
fn() => Doctrine\ORM\EntityManager::create($connectionOptions, $config, $eventManager)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
throw new App\Exception\BootstrapException($e->getMessage());
|
||||
}
|
||||
},
|
||||
|
||||
App\Doctrine\ReloadableEntityManagerInterface::class => DI\Get(App\Doctrine\DecoratedEntityManager::class),
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Doctrine;
|
|||
|
||||
use App\Entity\Interfaces\IdentifiableEntityInterface;
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Exception\ConnectionException;
|
||||
use Doctrine\ORM\Decorator\EntityManagerDecorator;
|
||||
use Doctrine\ORM\ORMInvalidArgumentException;
|
||||
|
||||
|
@ -16,6 +17,23 @@ final class DecoratedEntityManager extends EntityManagerDecorator implements Rel
|
|||
public function __construct(callable $createEm)
|
||||
{
|
||||
parent::__construct($createEm());
|
||||
|
||||
try {
|
||||
$this->getConnection()->getNativeConnection();
|
||||
} catch (ConnectionException $e) {
|
||||
if (2002 === $e->getCode()) {
|
||||
throw new \Exception(
|
||||
sprintf(
|
||||
'Could not connect to the database. Check the error log for additional information. (%s)',
|
||||
$e->getMessage()
|
||||
),
|
||||
$e->getCode()
|
||||
);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->createEm = $createEm(...);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user