php - Laravel Capsule: Catch PDOException -
i'm building gateway enable several instances of application communicate each other. connect different databases i'm using laravel's capsule.
when request on database fails log error reason unable catch exception properly. looking @ logs catch working after application still dying.
the code pretty basic:
try { // connection , request here } catch (pdoexception $e) { log::error('*************************************************************************'); log::error('failure reading franchise bdcs'); log::error('franchise: '.json_encode($franchise->site_url)); log::error('*************************************************************************'); }
in logs have following:
[2015-04-29 09:46:35] production.info: started reading ppfd [] []
[2015-04-29 09:46:35] production.error:
************************************************************************* [] []
[2015-04-29 09:46:35] production.error: failure reading franchise bdcs [] []
[2015-04-29 09:46:35] production.error: franchise: "https://ppfd.domain.net/" [] []
[2015-04-29 09:46:35] production.error:
************************************************************************* [] []
[2015-04-29 09:46:35] production.error: exception 'pdoexception' message 'sqlstate[hy000] [1045] access denied user 'test'@'pp.damain.net' (using password: yes)' in /var/www/fd/releases/20150423164018/vendor/laravel/framework/src/illuminate/database/connectors/connector.php:47
stack trace:
how can catch exception , allow code carry on instead of crashing?
thanks in advance. appreciated.
app::error(function(pdoexception $exception) { log::error($exception); });
read more: http://laravel.com/docs/4.2/errors
Comments
Post a Comment