REST: 404 error as HTML

so, i made rest app, but it doesn’t negotiate response content of 404 exception to Accept header. it always sends HTML data, as usual

what can i do to get same error message as i get from \yii\rest\Controller

p.s.

code in config like below doesn’t help too




'components' => [.....

		'response' => [

			'class' => 'yii\web\Response',

			'on beforeSend' => function ($event) {

				if ($event->sender->statusCode != 200) {

					/* @var $r \yii\web\Response */

					$r = $event->sender;					

					$accept = @Yii::$app->request->getHeaders()['Accept'];

					if ($accept == 'applicatioin/xml') {

						$r->format = yii\web\Response::FORMAT_XML;

					} else {

						$r->format = yii\web\Response::FORMAT_JSON;

					}

				}

			},

		],




i guess the only way is to handle error wiht yii\rest\controller

need to check