try{}catch{}

try{
Db::name('user')->find();
}catch(\Exception $e){
$this->error($e->getMessage());
}$
this-> success ( 'executed successfully!'); 

  


PHP can be used to capture the abnormal necessary treatment, but need a little attention, do not use in abnormal capture think \ Controller class
exception handling
--427--
of error, success and redirect method, since the above-mentioned three methods will throw HttpResponseException exceptions, thus affecting positive
constant exception caught, for example:


Guess you like

Origin www.cnblogs.com/dayin1/p/11888572.html