From ee4570f5d4148a5511db3f5e59ad7208d69f87c3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 8 Jul 2014 10:46:51 -0400 Subject: [PATCH] pcrud service improved error tracking Signed-off-by: Bill Erickson --- Open-ILS/web/js/ui/default/staff/services/pcrud.js | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/services/pcrud.js b/Open-ILS/web/js/ui/default/staff/services/pcrud.js index 5c4ec2f076..1f78b17ce2 100644 --- a/Open-ILS/web/js/ui/default/staff/services/pcrud.js +++ b/Open-ILS/web/js/ui/default/staff/services/pcrud.js @@ -38,7 +38,8 @@ */ 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 = {}; @@ -208,14 +209,24 @@ angular.module('egCoreMod') 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; -- 2.11.0