Thinkphp Exception Handling Mechanism

Source: Internet
Author: User
Note: 1. throwexception if it is not captured by the corresponding catch block, it will be passed to the top-level exception processor (if set) 2. the getTrace () method of the exception object can trace the function in which the exception is thrown. the exception information we want to handle generally includes four types: getMessage and getFile.

Note: 1. throwexception if it is not captured by the corresponding catch block, it will be passed to the top-level exception processor (if set) 2. the getTrace () method of the exception object can trace the function in which the exception is thrown. the exception information we want to handle generally includes four types: getMessage and getFile.

Note:
1. throw exception if it is not captured by the corresponding catch block, it will be passed to the top-level exception processor (if it is set)
2. The getTrace () method of the exception object can trace the function in which the exception is thrown.
3. The exception information to be processed generally includes four types: getMessage, getFile, getLine, and debug_print_backtrace)
4. thinkphp only throws an exception in two ways: 1. throw new throwing iton 2. throw_exception ().
5. After an exception is thrown, a catch block or top-level exception processor will be found. Other code will not be executed. <无>
  GetMessage (); $ trace = $ e-> getTrace (); // if throw_exception is thrown, the location where throw_exception is called is located. if ($ trace [0] ['function'] = 'Throw _ exception ') {$ error ['file'] = $ trace [0] ['file']; $ error ['line'] = $ trace [0] ['line'];} else {// directly throw an exception $ error ['file'] = $ e-> getFile (); $ error ['line'] = $ e-> getLine ();} // debug information // $ error ['track'] = debug_print_backtrace (); // call the exception template output to // include C ('temp _ EXCEPTION_FILE '); print_r ($ error) ;}} functio N throw_exception ($ message) {throw new Exception ($ message);} throw_exception ('exception thrown in the throw_exception Function !, Will locate the location of the throw_exception call ');
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.