'components' => [
'errorHandler' => [
'errorAction' => 'site/error',
],
...
class ApiController extends Controller {
public function init() {
parent::init();
Yii::app()->errorHandler->errorAction='api/error';
}
public function actionError(){
echo json_encode(array(
'Status'=>500,
'Message'=>'Unknown error'
));
}