In my controller i need to test custom database connection and if it's bad return an error. The problem is that catch
block doesn't work... I get an exception message which is globally defined in app/start/global.php
.
try {
DB::connection('test');
} catch (Exception $e) {
dd('error');
}
Laravel handles exceptions, no need for try/catch. You can write a custom exception inside \App\Exceptions and customise the contents of App\Exceptions\Handler.php to format the response of any individual exception to meet your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With