Home >Backend Development >PHP Tutorial >How to catch exceptions in try catch of TP3.2
Java code
public function t(){ try { throw new \Exception("haha"); }catch (Exception $e){ dump($e); } }
The above catch cannot be captured, and an ERROR page will appear. Because catch (Exception $e){ captures the Exception class of the current module, not Exception, so it needs to be changed to
Java code
public function t(){ try { E("errr"); }catch (\Exception $e){ dump($e); } }