From: miker Date: Tue, 5 Apr 2011 19:59:44 +0000 (+0000) Subject: More PermaCrud error handling cleanup X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=26c1b7520de45ed5ea2fec6e2c6555d491592a6b;p=contrib%2FConifer.git More PermaCrud error handling cleanup git-svn-id: svn://svn.open-ils.org/ILS/trunk@19987 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/js/dojo/openils/PermaCrud.js b/Open-ILS/web/js/dojo/openils/PermaCrud.js index eb67638c23..f1c4791510 100644 --- a/Open-ILS/web/js/dojo/openils/PermaCrud.js +++ b/Open-ILS/web/js/dojo/openils/PermaCrud.js @@ -296,7 +296,7 @@ if(!dojo._hasResource["openils.PermaCrud"]) { req.onerror = function (r) { _pcrud.disconnect(); - if (r._final_error) r._final_error(r); + if (req._final_error) req._final_error(r); else throw '_CUD: Error creating, deleting or updating ' + js2JSON(obj); }; @@ -307,16 +307,16 @@ if(!dojo._hasResource["openils.PermaCrud"]) { var res = r.recv(); if ( res && res.content() ) { _return_list.push( res.content() ); - _CUD_recursive( r._obj_list, r._pos, r._final_complete ); + _CUD_recursive( r._obj_list, r._pos, req._final_complete, req._final_error ); } else { _pcrud.disconnect(); - if (r._final_error) r._final_error(r); + if (req._final_error) req._final_error(r); else throw '_CUD: Error creating, deleting or updating ' + js2JSON(obj); } }; req.onerror = function (r) { _pcrud.disconnect(); - if (r._final_error) r._final_error(r); + if (req._final_error) req._final_error(r); throw '_CUD: Error creating, deleting or updating ' + js2JSON(obj); }; } @@ -435,20 +435,21 @@ if(!dojo._hasResource["openils.PermaCrud"]) { oncomplete : function (r) { var res = r.recv(); if ( res && res.content() ) { - if (r._final_complete) + if (req._final_complete) req._final_complete(req, _return_list); _pcrud.disconnect(); } else { _pcrud.disconnect(); - throw 'Transaction commit error'; + if (req._final_error) req._final_error(r); + else throw 'Transaction commit error'; } }, }).send(); }; req.onerror = function (r) { - if (r._final_error) r._final_error(r); _pcrud.disconnect(); + if (req._final_error) req._final_error(r); }; } else { @@ -457,10 +458,11 @@ if(!dojo._hasResource["openils.PermaCrud"]) { req.oncomplete = function (r) { var res = r.recv(); if ( res && res.content() ) { - _auto_CUD_recursive( r._obj_list, r._pos, r._final_complete, r._final_error ); + _auto_CUD_recursive( r._obj_list, r._pos, req._final_complete, req._final_error ); } else { _pcrud.disconnect(); - throw '_auto_CUD: Error creating, deleting or updating ' + js2JSON(obj); + if (req._final_error) req._final_error(r); + else throw '_auto_CUD: Error creating, deleting or updating ' + js2JSON(obj); } }; }