title: Set reason for thrown bad request in Yii 2
body: <p>I'm writing an API and I have to throw HTTP 400 bad request like below</p>
  
  <pre><code>if (!$model-&gt;validate()) {
      throw new BadRequestHttpException;
  }
  </code></pre>
  
  <p>and it works fine meaning that it displays the default HTTP 400 page (I have no views defined because I'm building an API)</p>
  
  <p>What I would like to achieve is to give some reason for the bad request error thrown so that who is using the API knows why his request is bad.</p>
  
  <p>Tried the following but with no success</p>
  
  <pre><code>if (!$model-&gt;validate()) {
      Yii::$app-&gt;response-&gt;content = 'This is the reason for your bad request';
      throw new BadRequestHttpException;
  }
  </code></pre>
  
  <p>any ideas?</p>