php - Implement Error Handling to my framework -


I am starting to implement the error handling in my framework and some advice on how to create it I'm looking for.

First of all tell me how my frame is currently built:

I want to separate the framework startup from application startup, so anyone within the application startup The error should also be specially managed by that class.

I think that there should be a class named Core_Error_exception , set the error report to E_ALL because the errors for my structure will remain strict PHP 5.3 , then as my application load, I will run the shutdown function function within that class to restore all the default values.

What to do to capture all the errors e_ * _ notice and not e_ * _ error and then before the application starts I say to the class that Application_Error_Exception w is looking out for errors.

I would need a way to track all errors including exceptions and triggers, and then show Framework debug page before starting the application.

The class I was looking for is like this:

Core_Error_Exception {var $ previus_error_level, $ captured content; Private $ stack_trace = array (); Public function Core_Error_Exception () {$ this- & gt; Previus_error_level = error_reporting (-1); Set_error_handler (array ($ this, '_ collect_error')); Set_exception_handler (array ($ this, '_ collect_error')); Ob_start (array ($ this, '_ capture')); } Public function _collect_error ($ errno, $ errstr, $ errfile, $ errlin, $ context) {$ this- & gt; Stack_trace [] = array (array ('name' = & gt; 'error id:', 'value' = ARE ('name' = 'gt;' error string: ',' value '=> $ errstr) , Array ('name' = & gt; 'error file:', 'value' => $ Errfile), array ('name' = & gt; 'error line:', 'value' => Errlin), array ('name' = & gt; 'prefix', 'value' = & gt; $ context)); var_dump ($ this-> stack_trace);} / * * _capture using pre_bufferd content Is done to capture. * / Public Function _capture ($ content, $ bitfield) {if ($ bitfield & amp; PHP_OUTPUT_HANDLER_START) {$ this-> constipation Content taken = $ Content;} If ($ BitField & amp; PHP_OUTPUT_HANDLER_CONT) {$ this-> Captured Content = $ Content;} If ($ BitField & amp; PHP_OUTPUT_HANDLER_END) {$ this- & gt; ; Content captured = $ content;} description is false;}} So what does it feel to be able to build this class in the way evidence of this fall? So that any notice errors may have been triggered in an array, If an e-op notice is called, then at that time the shutdown is automatically done to stop more errors.

I am using a small html template handler where I set that reference set errors, hence notification errors and a single e_ * _ error if applicable.

The best way to create this class like in the past is to do error tracking / reporting.

Renamed : With the current class

If errors have been triggered, such as trigger_up ('test', XXX); I want to be able to track all the errors unless the application launches or an E_USER_ERROR is triggered.

Sometimes I struggle to fully understand the error system of PHP, and in the same way, sometimes I get confused about how to put it, so its degradation-proof.

I'm not sure what you are doing, but in class applications

< The easiest way to use nested blocks with lines of pre> will be: Function run () {{--do stuff} catch {AppException $ e} {- Application-level exception handling} - All other exceptions Classes fall into the core: {$ core-> Try init ()); $ Application & gt; Run (); & Lt; - The above mentioned work calls $ core- & gt; Did (); } Hold (Exception $ E) - Never chance exception handler - Project exception was unable to operate on its own application}

php to be able to catch underlying errors or Trigger_error In this way, you should always install one.


Comments