title: Laravel Exception Handling - How to handle exceptions with both API and Html
body: <p>Api Call</p>
  
  <pre><code>http://localhost:8888/api/v1/users/100 //doesn't exist
  </code></pre>
  
  <p>Html Call</p>
  
  <pre><code>http://localhost:8888/admin/users/100 //doesn't exist
  </code></pre>
  
  <p>Obviously, I don't want the Html Call exception to return json data and I don't want the Api Call to return Html Data.</p>
  
  <p>I am not exception handling in the controller. I am exception handling in my UserRepository. As such, my controllers are just returning a result from the user repository.</p>
  
  <pre><code>class Sentry2UserRepository implements UserInterface {
  public function findById($id) {
      try {
          return Sentry::findUserById($id);
      }
      catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
      // Do something here
      return false;
          }
  }
  }
  </code></pre>
  
  <p>Question 1: What is the normal / proper way of passing an error back to controller so that it will know what to display?</p>
  
  <p>Question 2: Is there a standard json API format for exceptions / errors?</p>
  
  <p>Question 3: Is it good practice for a Web UI to consume an internal JsonApi? Or am I doing things the right way at the moment with my WebUi controllers Querying the same Repositories as the Api?</p>