title: Lumen 5.6 Error handling (throws exception twice)
body: <p>This is my code to handle any error:</p>
  
  <p>App\Exceptions\Handler::class</p>
  
  <pre><code>public function render($request, Exception $e)
  {
  
      $fe = \Symfony\Component\Debug\Exception\FlattenException::create($e);
  
      $statusCode = $fe-&gt;getStatusCode();
      $code       = $fe-&gt;getCode();
      $message    = $fe-&gt;getMessage();
  
      $errorObj = new \App\LOHDomain\Entities\Error($code, $message);
  
      return response()-&gt;json(['data' =&gt; null, 'error' =&gt; $errorObj], $statusCode);
  }
  </code></pre>
  
  <p>when I parse a fake WSDL URL to the SoapClient it throws two exceptions</p>
  
  <pre><code>{"data":null,"error":{"code":"0","message":"SOAP-ERROR: Parsing WSDL: Couldn't load from 'asdsd' : failed to load external entity \"asdsd\"\n"}}
  {"data":null,"error":{"code":"1","message":"SOAP-ERROR: Parsing WSDL: Couldn't load from 'asdsd' : failed to load external entity \"asdsd\"\n"}}
  </code></pre>
  
  <p>So the json response became invalid</p>
  
  <p>When commenting these line of codes in the vendor, it throws one exception:</p>
  
  <p>Laravel\Lumen\Concerns\RegistersExceptionHandlers trait</p>
  
  <pre><code>protected function registerErrorHandling()
  {
          error_reporting(-1);
  
          set_error_handler(function ($level, $message, $file = '', $line = 0) {
              if (error_reporting() &amp; $level) {
                  throw new ErrorException($message, 0, $level, $file, $line);
              }
          });
  
          set_exception_handler(function ($e) {
              $this-&gt;handleUncaughtException($e);
          });
  
  //        register_shutdown_function(function () {
  //            $this-&gt;handleShutdown();
  //        });
  }
  </code></pre>
  
  <p>So, What is the problem? and how to solve it without editing in the vendor?</p>