Custom error ThinkThink: appError design error !!

Source: Internet
Author: User
Us. php. netmanuzhfunction. Errors below the set-error-handler.php level cannot be handled by user-defined functions: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and in... http://us.php.net/manual/zh/function.set-error-handler.php

The following errors cannot be handled by user-defined functions: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of the E_STRICT generated in the file where the set_error_handler () function is called.

/*** Custom error handling * access public * @ param int $ errno Error Type * @ param string $ errstr error message * @ param string $ errfile error file * @ param int $ errline error row * return void */static public function appError ($ errno, $ errstr, $ errfile, $ errline) {switch ($ errno) {case E_ERROR: case E_PARSE: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: ob_end_clean (); $ errorStr = "$ errstr ". $ errfile. "Row $ errline. "; if (C ('Log _ RECORD ') LOG: write (" [$ errno] ". $ errorStr, Log: ERR); self: halt ($ errorStr); break; default: $ errorStr = "[$ errno] $ errstr ". $ errfile. "Row $ errline. "; self: trace ($ errorStr,'', 'notic '); break ;}}

However, thinkPHP's custom error method wants to handle these errors. How can this problem be solved? So this design is meaningless, right.

It's useless. I don't know what this design means. Please explain it!

This problem: http://segmentfault.com/q/1010000002703753/a-1020000002703757 I understand is right.

Reply content:

Http://us.php.net/manual/zh/function.set-error-handler.php

The following errors cannot be handled by user-defined functions: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of the E_STRICT generated in the file where the set_error_handler () function is called.

/*** Custom error handling * access public * @ param int $ errno Error Type * @ param string $ errstr error message * @ param string $ errfile error file * @ param int $ errline error row * return void */static public function appError ($ errno, $ errstr, $ errfile, $ errline) {switch ($ errno) {case E_ERROR: case E_PARSE: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: ob_end_clean (); $ errorStr = "$ errstr ". $ errfile. "Row $ errline. "; if (C ('Log _ RECORD ') LOG: write (" [$ errno] ". $ errorStr, Log: ERR); self: halt ($ errorStr); break; default: $ errorStr = "[$ errno] $ errstr ". $ errfile. "Row $ errline. "; self: trace ($ errorStr,'', 'notic '); break ;}}

However, thinkPHP's custom error method wants to handle these errors. How can this problem be solved? So this design is meaningless, right.

It's useless. I don't know what this design means. Please explain it!

This problem: http://segmentfault.com/q/1010000002703753/a-1020000002703757 I understand is right.

Thank you! I'm not a ThinkPHP user. I have to guess.

The significance of this design is that after trigger_error () is used in the Framework to trigger a user-level error, user-defined functions are used to generate developer-friendly output.

I guess the author thinks too much about the reasons for determining E_ERROR, E_PARSE, E_CORE_ERROR, and E_COMPILE_ERROR.

There should be no problem with this design. Many frameworks manage and capture errors by themselves. The advantage is that you can control the error display information by yourself during development and production, and use logs to locate errors.

The following errors cannot be handled by user-defined functions: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of the E_STRICT generated in the file where the set_error_handler () function is called.

After testing, the ob_start () series functions cannot control error output at the above level, and errors at the above level cannot be triggered by users, that is, trigger_error cannot be used for triggering.

Sorry, I am not a ThinkPHP user and do not like this, so I can't help you.

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.