title: Using success/error/finally/catch with Promises in AngularJS
body: <p>I'm using <code>$http</code> in AngularJs, and I'm not sure on how to use the returned promise and to handle errors. </p>
  
  <p>I have this code:</p>
  
  <pre><code>$http
      .get(url)
      .success(function(data) {
          // Handle data
      })
      .error(function(data, status) {
          // Handle HTTP error
      })
      .finally(function() {
          // Execute logic independent of success/error
      })
      .catch(function(error) {
          // Catch and handle exceptions from success/error/finally functions
      });
  </code></pre>
  
  <p>Is this a good way to do it, or is there an easier way? </p>