PHP中try{}catch{}是异常处理,将要执行的代码放入TRY块中,如果这些代码执行过程中某一条语句发生异常,则程序直接跳转到CATCH块中,由$e收集错误信息和显示。任何调用 可能抛出异常的方法的代码都应该使用try语句,Catch语句用来处理可能抛出的异常。
try {
$TemplatesObj = new Templates()
;
$this->mx_success(
$TemplatesObj->getTemplateInfo(
$affairs_template_id))
;
}
catch (
Exception $e)
{
$this->mx_error(
$e->getMessage())
;
}