title: Angular: Catch a 404 error on file not found
body: <p>In my Ionic project I am creating a function to find out if a file exists locally or not. I have created the following function:</p>
  
  <pre><code>$rootScope.eventFieldTemplateExists = function(field) {
      //var templateUrl = 'views/fields/' + field.name + '.html';
      var templateUrl = 'views/fields/testfile.html';
  
  
      $http.head(templateUrl).then(function(res) {
        console.log("success");
        console.log(res);
      })
      .catch(function(err) {
        console.log("catch");
        console.log(err);
      });
  
      return true;
  };
  </code></pre>
  
  <p>The file <code>testfile.html</code> does not exist. The above works fine when I enter a file that do exist, but I still get a console error when the file does not exist:</p>
  
  <pre><code>HEAD http://localhost:9000/views/fields/testfile.html 404 (Not Found)
  catch
  {data: "", status: 404, config: {…}, statusText: "Not Found", headers: ƒ}
  </code></pre>
  
  <p>Is there some way to suppress the error? I was hoping that the <code>.catch</code> would suppress it, but apparently it does not.</p>