[新手php]throw完一個exception,再re-throw, 新個個係咪會覆寫舊個個?

re-thow exception, 咁舊個個exception會點?

throw返舊果個咪留返
  1. try{
  2.      .....
  3. }catch(Exception $e){
  4.    if($cannotHandle){
  5.        throw $e;
  6.    }
  7. }
複製代碼
如果你想加資訊,咪new果時加埋舊果個落去
  1. try{
  2.      .....
  3. }catch(Exception $e){
  4.    if($cannotHandle){
  5.        throw new Exception("Some new messages", 0, $e);
  6.    }
  7. }
複製代碼

TOP