*/
angular.module('egCoreMod')
-.factory('egPCRUD', ['$q', 'egAuth', 'egIDL', function($q, egAuth, egIDL) {
+.factory('egPCRUD', ['$q','$rootScope','egAuth','egIDL',
+ function($q , $rootScope , egAuth , egIDL) {
var service = {};
oncomplete : function() {
deferred.resolve(lastResp);
},
- onmethoderror : function(e) {
- self.err(method + " failed " + e + "\n" + js2JSON(params));
- deferred.reject(e);
- },
- onerror : function(e) {
- self.err(method + " failed " + e + "\n" + js2JSON(params));
- deferred.reject(e);
+
+ onmethoderror : function(req, stat, stat_text) {
+ self.err(method + " failed. \ncode => "
+ + stat + "\nstatus => " + stat_text
+ + "\nparams => " + js2JSON(params));
+
+ if (stat == 401) {
+ // 401 is the PCRUD equivalent of a NO_SESSION event
+ $rootScope.$broadcast('egAuthExpired');
+ }
+
+ deferred.reject(req);
}
+ // Note: no onerror handler for websockets connections,
+ // because errors exist and are reported as top-level
+ // conditions, not request-specific conditions.
+ // Practically every error we care about (minus loss of
+ // connection) will be reported as a method error.
}).send();
return deferred.promise;