First it swap host not allowed by NotFoundHttpException ('Page not found') which is very misleading in the log.
Then it makes things even harder for developer by calling Yii::$app->end(); , making catch block unusable. If this happens in production , it would take days to locate the issue.
I dunno, maybe :
- send access denied error instead of not found ?!?
- don't end the app, let the dev handle the exception themselves ?