Is it necessary to always catch `Nette\Application\AbortException` when returning a Response from Presenter?
- matronator
- Member | 38
I was just writing code in our CRM at work and noticed a warning when using
$this->sendJson()
about unhandled exception
Nette\Application\AbortException
. I've seen this same warning many
times, so I assume every $this->send...()
method throws this
exception.
Is it then necessary to always wrap the response in a
try...catch
block? Because sending responses is a pretty common
thing, so it seems redundant to always have to catch the
AbortException
. Is it really necessary and what are the dangers of
not handling it?
Thanks!
- Marek Bartoš
- Nette Blogger | 1275
AbortException is just internal mechanism for finishing request processing,
you may completely ignore it.
I guess you are using PHPStorm? It likes to report most of the exceptions.
@DavidGrudl may we change exceptions that are not intended to be caught
to extend LogicException instead of Exception? That should suppress all IDE
warnings.