fixed some issues with the network failure handling
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Aug 2006 13:34:24 +0000 (13:34 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 8 Aug 2006 13:34:24 +0000 (13:34 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5360 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/RemoteRequest.js

index df92b13..f1b1840 100644 (file)
@@ -7,6 +7,9 @@ var XML_HTTP_MAX_TRIES = 3;
 /* This object is thrown when network failures occur */
 function NetworkFailure(stat) { this.status = stat; }
 NetworkFailure.prototype.status = function() { return this.status; }
+NetworkFailure.prototype.toString = function() { 
+       return "Network Failure: status = " + this.status; 
+}
 
 
 
@@ -262,13 +265,20 @@ RemoteRequest.prototype.getResultObject = function() {
        if(this.cancelled) return null;
        if(!this.xmlhttp) return null;
 
+       var failed = false;
+       var status = null;
+
        try {
-               if( this.xmlhttp.status != 200 ) {
-                       try{dump('! NETWORK FAILURE.  HTTP STATUS = ' 
-                               + this.xmlhttp.status);}catch(e){}
-                       throw new NetworkFailure(this.xmlhttp.status);
-               }
-       } catch(e) {}
+               status = this.xmlhttp.status;
+               if( status != 200 ) failed = true;
+       } catch(e) { failed = true; }
+
+
+       if( failed ) {
+               if(!status) status = '<unknown>';
+               try{dump('! NETWORK FAILURE.  HTTP STATUS = ' +status);}catch(e){}
+               throw new NetworkFailure(status);
+       }
 
 
        this.event(null);