title: Laravel - Catch exception in custom handler
body: <p>I'm using Laravel 5.5 and I want to handle my custom exceptions from custom handlers, not from <code>app\Exceptions\Handler.php</code>. Now, I catch an exception if some field it's empty in the form submitted by the user. It's perfectly working like this:</p>
  
  <ol>
  <li><p><strong>ProfileController.php</strong>:</p>
  
  <pre><code>public function update(Request $request, $id){
      $this-&gt;guzzleService-&gt;put(
          $request,
          ApiEndPoints::UPDATE_PROFILE . $id,
          true
      );
  
      return back()-&gt;with('SavedCorrectly', 'Changes saved correctly');
  }
  </code></pre></li>
  <li><p><strong>app\Exceptions\Handler.php</strong></p>
  
  <pre><code>public function render($request, Exception $exception)
  {
      if($exception instanceof ClientException &amp;&amp; $exception-&gt;getCode() == 422)
          return back()-&gt;withErrors(
              json_decode((string) $exception-&gt;getResponse()-&gt;getBody(), TRUE)["errors"]
          );
  
      return parent::render($request, $exception);
  }
  </code></pre></li>
  </ol>
  
  <p>The problem is that I want to refactor that, so that it remains like this:</p>
  
  <ol>
  <li><p><strong>ProfileController.php</strong></p>
  
  <pre><code>public function update(Request $request, $id){
      try {
          $this-&gt;guzzleService-&gt;put(
              $request,
              ApiEndPoints::UPDATE_PROFILE . $id,
              true
          );
  
          return back()-&gt;with('SavedCorrectly', 'Cambios guardados correctamente');
      } catch(ClientException $exception) {
          if ($exception-&gt;getCode() == 500) throw new InternalServerErrorException;
          if ($exception-&gt;getCode() == 422) throw new UnprocessableEntityException;
      }
  }
  </code></pre></li>
  <li><p><strong>app\Exceptions\HttpExceptions\UnprocessableEntityException.php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Exceptions\HttpExceptions;
  
  use GuzzleHttp\Exception\ClientException;
  
  class UnprocessableEntityException extends \Exception
  {
      public function render($request, ClientException $exception)
      {
          return back()-&gt;withErrors(
              json_decode((string) $exception-&gt;getResponse()-&gt;getBody(), TRUE)["errors"]
          );
      }
  }
  </code></pre></li>
  </ol>
  
  <p>But I'm receiving this error:</p>
  
  <blockquote>
    <p>Type error: Argument 2 passed to
    App\Exceptions\HttpExceptions\UnprocessableEntityException::render()
    must be an instance of GuzzleHttp\Exception\ClientException, none
    given, called in
    ... \vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php
    on line 169</p>
  </blockquote>