ErrorController.php
999 Bytes
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
<?php
/**
* This is error handler configured as global
*
*/
class ErrorController extends WRestController
{
public function actionError() {
if($error = Yii::app()->errorHandler->error) {
if(YII_DEBUG) {
$this->sendResponse($error['code'], array(
'success' => false,
'error' => $error
));
}
else {
if(Yii::app()->user->isGuest) {
$this->sendResponse(401, array(
'success' => false
));
}
else {
$this->sendResponse($error['code'], array(
'success' => false,
'error' => array(
'message' => $error['message']
))
);
}
}
}
else {
Yii::app()->end();
}
}
}