ErrorController.php
3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* ErrorController - The default error controller class
*
* @author
* @version
*/
class ErrorController extends QLib_Controller_Action {
/**
* This action handles
* - Application errors
* - Errors in the controller chain arising from missing
* controller classes and/or action methods
*/
public function errorAction() {
$errors = $this->_getParam('error_handler');
if (isset($errors->exception) && $errors->exception instanceof QLib_Exception) {
echo 'QLib库出现错误' . (($iCode = $errors->exception->getCode()) ? '(' . $iCode . ')' : '') . ',原因为:' . $errors->exception->getMessage();
die();
}
if (isset($errors->exception) && $errors->exception instanceof Q_Exception) {
echo 'Q框架出错' . (($iCode = $errors->exception->getCode()) ? '(' . $iCode . ')' : '') . ',原因为:' . $errors->exception->getMessage();
die();
}
switch ($errors->type) {
//case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER :
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION :
// 404 error -- controller or action not found
$this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
$this->view->title = 'HTTP/1.1 404 Not Found';
break;
default :
// application error; display error page, but don't change
$app_error_meg = " Date: " . date('Y-m-d H:i:s') . "\n";
$app_error_meg .=" Type: " . $errors->type . "\n";
$app_error_meg .=" Code: " . $errors->exception->getCode() . "\n";
$app_error_meg .=" Exception: " . $errors->exception->getCode() . "\n";
$app_error_meg .=" File: " . $errors->exception->getFile() . "\n";
$app_error_meg .=" Line: " . $errors->exception->getLine() . "\n";
$app_error_meg .=" Referer: ". ( !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '' ) . "\n";
$app_error_meg .=" Request_uri: ". ( !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '' ) . "\n";
$app_error_meg .=" IP: ". ( !empty($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : '' ) . "\n";
$app_error_meg .=" Http_cookie: \n ". ( !empty($_SERVER["HTTP_COOKIE"]) ? $_SERVER["HTTP_COOKIE"] : '' ) . "\n";
$app_error_meg .=" Server_port: ". ( !empty($_SERVER["SERVER_PORT"]) ? $_SERVER["SERVER_PORT"] : '' ). "\n";
$app_error_meg .=" Script_url: ". ( !empty($_SERVER['SCRIPT_URI']) ? $_SERVER['SCRIPT_URI'] : '' ) . "\n";
$app_error_meg .=" Message: \n " . $errors->exception->getMessage() . "\n";
$app_error_meg .=" Exception: \n " . $errors->exception . "\n\n";
@error_log($app_error_meg, 3, '/tmp/validateAppError.'.date('Ymd').'.log');
$this->view->title = 'Application Error';
$this->view->message = $errors->exception->getCode() . ':' . $errors->exception->getMessage();
break;
}
$this->view->message = '';
if (defined('RELEASE_ENV') && RELEASE_ENV != 'release') {
$this->view->message = $errors->exception->getMessage();
$this->view->exception = $errors->exception;
$this->view->request = $errors->request;
}
}
public function messageAction() {
}
public function __call($name, $arguments) {
$this->messageAction();
}
}