$error, 'backtrace'=>$backtrace, 'included'=>$included ); Router::clear(); switch(error_handle_type()){ case 'json': Router::json($context); break; case 'html':default: Router::write( Bugs::template('error') ->run(new Arguments($context)) ); } die(); } set_error_handler(function($errno, $errstr, $errfile, $errline){ handle_error( array( 'type'=> $errno, 'message'=> $errstr, 'file'=> $errfile, 'line'=> $errline ), debug_backtrace(), get_included_files() ); },E_ALL); register_shutdown_function(function(){ $error = error_get_last(); if(!is_null($error) && $error['type'] == 1){ handle_error( $error, debug_backtrace(), get_included_files() ); } }); ?>