【发布时间】:2020-06-25 15:37:45
【问题描述】:
就我而言,不需要任何参数。换句话说,应用程序不希望通过 post、get 或 put 获得任何数据。但是,在实现中,应首先定义会话变量中存储的项目列表,即购物车项目之类的东西,用户收集项目,然后转到下面的操作,否则会引发 HTTP 错误。查看以下示例:
public function actionCreate(){
if(count(Yii::$app->session->get('versesList',[])) > 0){
// Do the logic
}
else{
throw new \yii\web\BadRequestHttpException(Yii::t('app', 'You must collect some verses first!'));
}
}
我不太清楚,400 bad request 是否是正确的错误代码。我曾尝试在维基百科上阅读List of HTTP status codes,但我对其他一些 HTTP 错误感到困惑,例如:406 Not Acceptable、412 Precondition Failed、422 Unprocessable Entity
【问题讨论】:
标签: http web http-error