On the problem of abnormal (errorHandle) of Yii2

an uncertified API application

first of all, the Controller base class behaviors method is the default, inheriting only \ yii\ rest\ Controller , without adding additional authentication, and then customizing site/error

class TokenAuth extends \yii\filters\auth\HttpBasicAuth
{
    public function authenticate($user, $request, $response)
    {
        ...
        
        if(...)
        {
            throw new BadRequestHttpException("");
        }
        
        ...
    }
}

the problem is:
throws an exception in this method does not get a correct response , for example, the above should be 400, but it is actually 500, but it behaves normally in other behaviors , such as Verbfilter using incorrect HTTP verbs will get the correct exception return value. then what are the possibilities of this error

Mar.29,2021
Menu