title: Error handling with try and catch in Laravel
body: <p>I want to implement a good error handling in my app, I have forced this file for catching the error.</p>
  
  <p><strong>App\Services\PayUService</strong></p>
  
  <pre><code>try {
    $this-&gt;buildXMLHeader; // Should be $this-&gt;buildXMLHeader();
  } catch (Exception $e) {
          return $e;
  }
  </code></pre>
  
  <p><strong>App\Controller\ProductController</strong></p>
  
  <pre><code>function secTransaction(){
    if ($e) {
      return view('products.error', compact('e'));
    }
  }
  </code></pre>
  
  <p>And this is what I get.</p>
  
  <p><a href="https://i.stack.imgur.com/S205A.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S205A.png" alt="enter image description here"></a></p>
  
  <p>I don't know why Laravel is not redirecting me to the view.
  Is the error forced right?</p>