1
0
mirror of https://github.com/danog/amp.git synced 2024-12-03 18:07:57 +01:00

Improve factory error messages

This commit is contained in:
Niklas Keller 2016-05-19 15:51:47 +02:00
parent f890d37e80
commit 1c1e740392

View File

@ -74,14 +74,14 @@ final class Loop
private static function createDriver()
{
if (self::$factory === null) {
throw new \LogicException("Can't create an event loop driver without a factory.");
throw new \LogicException("No loop driver factory set; Either pass a driver to Loop::execute or set a factory.");
}
$driver = self::$factory->create();
if (!$driver instanceof LoopDriver) {
$type = is_object($driver) ? "an instance of " . get_class($driver) : gettype($driver);
throw new \LogicException("Factory returned {$type}, but must return an instance of LoopDriver.");
throw new \LogicException("Loop driver factory returned {$type}, but must return an instance of LoopDriver.");
}
return $driver;