This is a piece of code that I wrote, inside the PHP exception function, the error code to display errors when the line is displayed. When the user action error, give me, I can quickly have to track and troubleshoot errors!
Public functionAdded_business_submit () {Try{ Extract($_post); if("' = =$title) Self::json (0,sprintf(Error_empty, ' ticket title ')); if("' = =$is _trusteeship) Self::json (0,sprintf(Error_empty, ' Server class ')); if("' = =$eqroom _id) Self::json (0,sprintf(Error_empty, ' location of the room ')); M ()-Starttrans (); $com _info= M (' company ')->where (Array(' Com_qyuserid ' =$com _qyuserid)),find (); $com _id=$com _info[' com_id ']; $com _name=$com _info[' Com_name ']; if(Empty($com _info))Throw New Exception(Error_notfound_user); $data=Array( ' com_id ' =$com _id, ' com_name ' =$com _name, ' type ' = 1, ' Step ' = 1, ' poster ' + Self::$user[' name '], ' posttime ' = + Self::$datetime, ' Eqroom_name ' + D (' Equiproom ')->get_eqroom_name ($eqroom _id), ); $data=Array_merge($data,$_post); $agent _id= M (' working_agent ')->add ($data); if(false===$agent _id)Throw New Exception(Error_submit); $result= D (' steplogagent ')->next_step ($agent _id,$remark); if(false===$result)Throw New Exception(Error_submit); }Catch(Exception $e) {M ()-rollback (); $this->exception_handle ($e); } M ()-commit (); Self:: JSON (1,success_submit);}Private functionException_handle (Exception $e){ $msg=$e-GetMessage (); $line=$e-GetLine (); //**/print_r ($e); Echo M ()->getlastsql (); $name= Self::$user[' Name ']; $time= Self::$datetime; $sql= M ()Getlastsql (); $log=$time." ".$name.":{$msg}({$line}) {$sql}"; Self:: MyLog ($log, ' Agent '); Self:: JSON (0, "{$msg}({$line})");}
A section of PHP exceptions