I'm trying to develop a micro app and struggle with error handling. I've seen the
$app->error(), my main bootstrap is encapsuled in a try/catch also, and so on, but don't know which one to use.
First question is: I cannot see which benefit I have when using
$app->error() instead of
set_exception_handler. When using the latter one I can catch
\Error also and not only
\Exception. So, why should I use the error-handler of the application?
Second question: When any error occurs, I simply want to send a 500 error to user without any custom error page and want this error to be logged to error file. What approach is useful? Writing custom handlers for errors and exceptions or let PHP handle it via
error_log=<filename>? When using the latter one, it seems to me, that I can remove all custom handlers and the try/catch block for bootstrap, can't I?