jeudi 26 novembre 2020

Using try catch in laravel

I have to send mail and messages on mobiles so i want if mail or mobile messages gateway throws any error then rest of the code should not stop working. So i have used below try and catch block. Should i place both mobile otp and email in one single try catch block or there will be different try catch for both.

try{
       $mobile = \App\Helpers\Helper::sendMessage($request->mobile,'message');
    }
    catch (\Exception $e) { 
       
    }

    try{
        Mail::to($request->email)->send(new Mail($data));
    }
    catch (\Exception $e) { 
       
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire