code: function cancel(reason, options) {
          var interim = showingInterims.pop();
          if (!interim) {
            return $q.when(reason);
          }
  
          var cancelAction = interim
            .remove(reason, true, options || {})
            .catch(function(reason) { return reason; })
            .finally(function() {
              hidePromises.splice(hidePromises.indexOf(cancelAction), 1);
            });
  
          hidePromises.push(cancelAction);
  
          // Since AngularJS 1.6.7, promises will be logged to $exceptionHandler when the promise
          // is not handling the rejection. We create a pseudo catch handler, which will prevent the
          // promise from being logged to the $exceptionHandler.
          return interim.deferred.promise.catch(angular.noop);
        }
docs: /*
  @ngdoc method
  @name $$interimElement.$service#cancel
  @kind function
  
  @description
  Removes the `$interimElement` from the DOM and rejects the promise returned from `show`
  
  @param {*} reason Data to reject the promise with
  @returns Promise that will be resolved after the element has been removed.