草庐IT

CreateContactException

全部标签

php - 新手 : throw new exception - can we change exception name?

我正在尝试处理异常(exception)情况。所以我有类似的东西:如果发生不好的事情:thrownewCreateContactException($codigo,$result->msg);稍后,我会尝试,如果不行,捕获:try{createContact();}catch(CreateContactException$e){$error.='Anerroroccurredwiththecode:'.$e->getCode().'andmessage:'.$e->getMessage();}1)这行得通吗?我的意思是,这个getCode()和getMessage()与CreateCo