title: Laravel form request return authorization failed with custom message
body: <p>In my Laravel (7.x) application, I am using <code>ajax</code> to <code>validate &amp; submit</code> the form. I am using <code>form request</code> to validate the field. Till here everything is working completely fine.</p>
  <p>However, while handling the user authorization using <code>Laravel Gates</code>, I am getting exception instead of returning json errored response.</p>
  <p>ValidateRequest.php:</p>
  <pre class="lang-php prettyprint-override"><code>class ValidateRequest extends FormRequest
  {
      /**
       * Determine if the user is authorized to make this request.
       *
       * @return bool
       */
      public function authorize()
      {
          # access
          return Gate::allows('admin');
      }
  
      ...
  }
  </code></pre>
  <p>Here is the exception:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;message&quot;: &quot;This action is unauthorized.&quot;,
      &quot;exception&quot;: &quot;Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException&quot;,
      &quot;file&quot;: &quot;&lt;path&gt;\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php&quot;,
      &quot;line&quot;: 225,
      &quot;trace&quot;: [        
          ...
      ]
  }
  </code></pre>
  <p>I need to set and return the custom message via ajax response.</p>
  <p>Something like this:</p>
  <pre class="lang-php prettyprint-override"><code>{
     'status': 422,
     'error': 'You are not authorized to access this area'
  }
  </code></pre>