Laravel 5 - How do you get the Mail :: send () error?

I have the following method that sends an email:

Mail::send('emails.configuration_test', array(), function($email)use($request){ $email->to($request->test_address)->subject('Configuration Test'); }); 

If the above errors are missing, I would like to catch an exception. When I use the following:

 try{ Mail::send('emails.configuration_test', array(), function($email)use($request){ $email->to($request->test_address)->subject('Configuration Test'); }); } catch(Exception $e){ // Never reached } 

exception never gets caught. Instead, I get a stack of Laravel as an answer if send() errors are missing.

How can I catch the exception in this case?

+5
source share
1 answer

Using the root namespace \Exception did the trick.

Instead:

 catch(Exception $e){ // Never reached } 

I used:

 catch(\Exception $e){ // Get error here } 
+12
source

Source: https://habr.com/ru/post/1262443/


All Articles