i tend to use
try {
..... code
} catch(PDOException $e){
..... return / display error etc
}
But depends how your code with the issue is etc. With whoops have you got the Debug set to true so you get a great big orange page of errors that will display a more indepth reason etc?
simondavies said:
i tend to use
try { ..... code } catch(PDOException $e){ ..... return / display error etc }
But depends how your code with the issue is etc. With whoops have you got the Debug set to true so you get a great big orange page of errors that will display a more indepth reason etc?
Normally that's how I'd catch exceptions, too. In this case, though, I'm not controlling the database connections (Laravel is) so don't want to have to wrap any of the Laravel code in try/catch blocks.
Re Whoops - yes, I have debug set to true as per default. The big orange page just shows the final exception as PDOException - that's what I'm trying to catch.
cools thanks for clarifying this, sorry. What are if any you getting within the error log?
could you try:
Log:error( $exception->getMessage() );
Etc?
simondavies said:
cools thanks for clarifying this, sorry. What are if any you getting within the error log?
could you try:
Log:error( $exception->getMessage() );
You missed a colon. ;-)
Etc?
There are two scenarios I'm trying to deal with here.
I'm not sure why but in neither of those cases does anything get written to app/storage/logs/laravel.log. I thought it would be because of the event listener that writes errors the database, but I've commented the section and still nothing gets written to app/storage/logs/laravel.log
In fact, nothing is written there at all, unless the application is running without any problems. Exceptions are logged there if I make a mistake in my code, but "system" errors are not (e.g. MySQL connection problems as described above). That pretty much makes laravel.log useless.
Log::error calls do work, but again only if the database is running properly.
See if this helps - Using App::before to trap/catch PDOException Errors (http://www.laravel-tricks.com/tricks/using-appbefore-to-trapcatch-pdoexception-errors)
You can use App::before to catch a connection error
DragonI said:
See if this helps - Using App::before to trap/catch PDOException Errors (http://www.laravel-tricks.com/tricks/using-appbefore-to-trapcatch-pdoexception-errors)
You can use App::before to catch a connection error
@Dragonl it seems that you are not remembering why you use App:before when reading that link and your response to the comment.
Did you come up with an understanding and response to if there are any reason not to use App::error as a wrapper? Guess you are just registering an event listener that lives for eternity (until webserver is stopped) in either way...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community