response->format = \yii\web\Response::FORMAT_JSON; parent::init(); } /** * beforeAction * @return bool * @throws Exception */ public function beforeAction($action) { try { return parent::beforeAction($action); } catch (\Exception $e) { throw new Exception($e->statusCode, $e->getMessage()); } } }