EDIT: SEE THE ANSWER BELOW
I have a function:
dataFactory.getCurrentStepId(wf.identifier, ctx.identifier)
.then(function (data) {
console.log('then');
$timeout(function () {
$("#app-node-" + data.identifier)
.parent().parent().css("border", "5px solid green");
});
})
.catch(function () {
console.log('error');
alert('Error!')
});
The getCurrentStepId
has an exception, and I see the error printed on the console for the AJAX request it sends, but my alert and console.log don't fire in the catch.
Any ideas why? Here is the stuff it's calling:
app.factory('dataFactory', function ($http, $q) {
var _baseUrl = webServiceContext;
var _doGet = function (endpoint) {
var deferred = $q.defer();
$http.get(_baseUrl + '/' + endpoint).then(function (response) {
deferred.resolve(response.data);
});
return deferred.promise;
};
var getCurrentStepId = function (wid, cid) {
return _doGet('wf/step/' + wid + '/' + cid);
};
})
Here is the answer
@Blunderfest almost got it right:
$http.get(_baseUrl + '/' + endpoint).then(function (response) {
deferred.resolve(response.data);
}).catch(function(e){return deferred.reject(e);});