Skip to content

Commit 4f3b250

Browse files
committed
PresenterFactoryCallback: throws error "Refresh browser" when DI is unable to create presenter instance
It may be caused by 'di > export > types' setting.
1 parent e0b2675 commit 4f3b250

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Bridges/ApplicationDI/PresenterFactoryCallback.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,16 @@ public function __invoke(string $class): Nette\Application\IPresenter
4747
touch($this->touchToRefresh);
4848
}
4949

50-
$presenter = $this->container->createInstance($class);
51-
$this->container->callInjects($presenter);
50+
try {
51+
$presenter = $this->container->createInstance($class);
52+
$this->container->callInjects($presenter);
53+
} catch (Nette\DI\MissingServiceException | Nette\DI\ServiceCreationException $e) {
54+
if ($this->touchToRefresh && class_exists($class)) {
55+
throw new \Exception("Refresh your browser. New presenter $class was found.", 0, $e);
56+
}
57+
throw $e;
58+
}
59+
5260
if ($presenter instanceof Nette\Application\UI\Presenter && $presenter->invalidLinkMode === null) {
5361
$presenter->invalidLinkMode = $this->invalidLinkMode;
5462
}

0 commit comments

Comments
 (0)