-
-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to check wheather database is down or not #296
Comments
@AviRns good point on how to check database maintenance. I think we can throw some custom error exception that you can catch via Laravel's error handler. Maybe something like: if (! $this->dbh) {
$e = oci_error();
if ($e['code'] == 'Maintenance Error Code') {
throw new MaintenanceException($e['message'], 0, $e);
}
throw new Oci8Exception($e['message']);
} You can then catch this exception on your Laravel handler. public function render($request, Exception $exception)
{
if ($exception instanceof MaintenanceException) {
return 'something friendly?';
}
return parent::render($request, $exception);
} Just an idea and will try to play with this when I got the chance. Or if you can, please do not hesitate to submit a PR. Thanks! |
Maybe, we should also do a try catch instead of suppressing the error? |
@yajra Try Catch +1 |
@yajra +1 on custom error handling for DB connection. Would it be possible to provide a configuration option that would enable more exception handling for this specifically? I don't just mean for maintenance exceptions... for example, if the database connection fails for any reason, I would like to do the following: (1) redirect the user to an error page (or at least display a custom message) This is much easier to achieve if I could--for example--set a custom Exception object to check for in the Laravel Exception Handler render() function. Something like this:
The benefit of a custom exception class is that that there would be more flexibility in handling errors without changing the current error/debugging experience for developers (so long as they don't change their config settings). Alternatively, if not a customExceptionClass in the configuration, could there be a config option that would take an array of errorCode => exceptionClass values? |
Hi Yajra,
Many thanks for all your supports.
in case my database is down for maintenance, do you have some method that checks it.
or Refer to Oci8.php line 466, can we return some values if the database didnot connect instead of just throwing Oci8Exception?
Please help
Refer to Oci8.php line 466
The text was updated successfully, but these errors were encountered: