How catch error if Nette presenter in the {plink “presenter”} does not exist
Notice: This thread is very old.
- koudis
- Member | 33
Hi,
I have small problem with catching errors in the {plink “presenter”}
if the “presenter” does not exist I will get as return value of
“plink” function
""error: Cannot load presenter ‘<presenter>’, class
‘<presenter>Presenter’ was not found in
‘<presenter_path>’"
How I catch this error in the php code?
Thanks (and sorry for my english)
Koudis
Last edited by koudis (2013-08-22 17:44)
- Majkl578
- Moderator | 1364
You can temporarily switch an
error mode for invalid links to throw exceptions, catch them and then
restore previous mode.
Like this, in presenter:
use Nette\Application\UI\InvalidLinkException;
$old = $this->invalidLinkMode;
$this->invalidLinkMode = self::INVALID_LINK_EXCEPTION;
try {
$link = $this->link('Invalid');
} catch (InvalidLinkException $e) {
// handle invalid link
$link = '#';
} finally {
$this->invalidLinkMode = $old;
}