Home How should I set up asynchronous error handling with promises in angular?
 Currently, the flow in my application looks something like this function searchAsync() { $scope.search.inProgress = true; return Service.search($scope.search.parameters).$promise .then(function (data) {$scope.search.data = data; }).catch(function (e) { displayError(e); }).finally(function () { $scope.search.inProgress = false; }); } function initialize() { var promises = []; promises.push(setLookupsAsync($scope.categories, LookupResource.getCategories)); promises.push(setLookupsAsync($scope.topics, LookupResource.getTopics)); promises.push(setLookupsAsync($scope.races, LookupResource.getRaces)); promises.push(setLookupsAsync($scope.genders, LookupResource.getGenders));$q.all(promises).then(function () { searchAsync() }).catch(function (e) { displayError(e); }).finally(function () { $scope.page.loaded = true; }); }  I've found that if the promise inside the searchAsync function fails, the error handling is local to that promise and the outside caller has no way of knowing if it failed or not. If I needed to access the$scope.search.data after the searchAsync call in the \$q.all 'then' piece, I would have no way of knowing if it had no items due to a handled catch or due to no matching items. Is there a cleaner way I can set up my error handling when working with promises?