/** * cli模式下的异常处理 * * @param Exception $e * @return string */ function cliErrorHandler(Exception $e) { $trace = $e->getTrace(); $trace_table = array(); if (!empty($trace)) { foreach ($trace as &$t) { if (isset($t['file'])) { $t['file'] = $this->hiddenFileRealPath($t['file']); } foreach ($t as $t_key => $t_info) { switch ($t_key) { case 'file': case 'line': case 'function': $t_info_length = max(strlen($t_key), strlen($t_info)); if (!isset($trace_table[$t_key]) || $t_info_length > $trace_table[$t_key]) { if ($t_info_length % 2 != 0) { $t_info_length += 9; } else { $t_info_length += 8; } $trace_table[$t_key] = $t_info_length; } break; } } } } $result['line'] = $e->getLine(); $result['file'] = $this->hiddenFileRealPath($e->getFile()); $result['trace'] = $trace; $result['trace_table'] = $trace_table; return Response::getInstance()->display($result, __DIR__ . '/_tpl/cli_error.tpl.php'); }
function errorHandler(Exception $e) { $cp_error = $this->cpExceptionSource($e); $code = $e->getCode() ? $e->getCode() : 500; return Response::getInstance()->setResponseStatus($code)->display($cp_error, __DIR__ . '/_tpl/front_error.tpl.php'); }
/** * @return Response */ function getResponse() { return Response::getInstance(); }