function ark_handle_shutdown() { $error = error_get_last(); if (isset($error)) { _exception_handler($error['type'], $error['message'], $error['file'], $error['line']); } }
public function __call($method, $args = array()) { if (in_array($method, $this->methods)) { return call_user_func_array(array($this->parent, $method), $args); } $trace = debug_backtrace(); _exception_handler(E_ERROR, "No such method '{$method}'", $trace[1]['file'], $trace[1]['line']); exit; }
public function ExceptionHandler(Exception $exception) { $class = get_class($exception); $message = $exception->getMessage(); $file = $exception->getFile(); $line = $exception->getLine(); $error = sprintf("Uncaught exception '%s' with message '%s'", $class, $message); // give CI a chance to handle the error (display message, logging) _exception_handler(E_ERROR, $error, $file, $line); // bubble up if necessary if ($this->previousHandler) { $this->previousHandler($exception); } // let PHP handle the rest. throw $exception; }
public function phpFunctions() { $arg_list = func_get_args(); $function = array_shift($arg_list); if (is_callable($function)) { return call_user_func_array($function, $arg_list); } if (!$this->env->isDebug()) { return null; } $trace = debug_backtrace(null, 2); $debugInfo = $this->getDebugInfo($trace); $errMsg = 'Called to an undefined function : <b>php_' . $function . "</b> "; if (isset($debugInfo['file'], $debugInfo['line'])) { _exception_handler(E_USER_NOTICE, $errMsg, $debugInfo['file'], $debugInfo['line']); } else { trigger_error($errMsg, E_USER_NOTICE); } return NULL; }
/** * Shutdown Handler * * This is the shutdown handler that is declared at the top * of CodeIgniter.php. The main reason we use this is to simulate * a complete custom exception handler. * * E_STRICT is purposivly neglected because such events may have * been caught. Duplication or none? None is preferred for now. * * @link http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a * @return void */ function _shutdown_handler() { $last_error = error_get_last(); if (isset($last_error) && $last_error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING)) { _exception_handler($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']); } }
function http_build_query($formdata, $numeric_prefix = NULL, $separator = NULL) { // Check the data if (!is_array($formdata) && !is_object($formdata)) { $backtrace = debug_backtrace(); _exception_handler(E_USER_WARNING, 'http_build_query() Parameter 1 expected to be Array or Object. Incorrect value given', $backtrace[0]['file'], $backtrace[0]['line']); return FALSE; } // Cast it as array if (is_object($formdata)) { $formdata = get_object_vars($formdata); } // If the array is empty, return NULL if (empty($formdata)) { return NULL; } // Argument separator if ($separator === NULL) { $separator = ini_get('arg_separator.output'); if (strlen($separator) == 0) { $separator = '&'; } } // Start building the query $tmp = array(); foreach ($formdata as $key => $val) { if ($val === NULL) { continue; } if (is_integer($key) && $numeric_prefix != NULL) { $key = $numeric_prefix . $key; } if (is_resource($val)) { return NULL; } // hand it off to a recursive parser $tmp[] = _http_build_query_helper($key, $val, $separator); } return implode($separator, $tmp); }
*/ $EXT->call_hook('post_controller_constructor'); /* * ------------------------------------------------------ * Call the requested method * ------------------------------------------------------ */ try { call_user_func_array(array(&$CI, $method), $params); } catch (Exception $exception) { $OUT->set_status_header($exception->getCode(), lang($exception->getMessage())); if (!$IN->accept('application/json')) { if (in_array(ENVIRONMENT, array('testing', 'production'))) { show_error(lang($exception->getMessage()), $exception->getCode()); } elseif (ENVIRONMENT === 'development') { _exception_handler(E_NOTICE, lang($exception->getMessage()), $exception->getFile(), $exception->getLine()); } } } // Mark a benchmark end point $BM->mark('controller_execution_time_( ' . $class . ' / ' . $method . ' )_end'); /* * ------------------------------------------------------ * Is there a "post_controller" hook? * ------------------------------------------------------ */ $EXT->call_hook('post_controller'); /* * ------------------------------------------------------ * Send the final rendered output to the browser * ------------------------------------------------------
/** * @param $methodName * @return null */ private function _handle_exception($methodName) { if (!function_exists('_exception_handler')) { return null; } $trace = debug_backtrace(null, 1); $errMsg = 'Undefined method : ' . get_class($this) . "::" . $methodName . " called"; _exception_handler(E_USER_NOTICE, $errMsg, $trace[0]['file'], $trace[0]['line']); }