[fusion-trac] #304: unknown error when zoom with disconnected server connection

Fusion trac_fusion at osgeo.org
Fri Dec 11 03:29:24 EST 2009


#304: unknown error when zoom with disconnected server connection
--------------------------+-------------------------------------------------
 Reporter:  christinebao  |         Owner:  madair  
     Type:  defect        |        Status:  assigned
 Priority:  P2            |     Milestone:  Future  
Component:  Core          |       Version:  1.1.1   
 Severity:  Major         |    Resolution:          
 Keywords:  Failover      |   External_id:  1250151 
    State:  New           |       Browser:  All     
       Os:  All           |  
--------------------------+-------------------------------------------------
Comment (by christinebao):

 == Tech diagnosis: ==

 Typically an error is handled in this way:

 1. If an exception occurs in MapGuide server, the server will throw out
 exception, and web tier will translate it into an HTML page, for example:
 [[BR]]

 {{{

 <html>
 <head>
 <title>MgDbException</title>
 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
 </head>
 <body>
 <h2>An exception occurred in DB component.</h2>
 An exception occurred in DB component.
 </body>
 </html>

 }}}
 [[BR]]

 2. Fusion get the response, and put the HTML content into its error
 handler.[[BR]]

 {{{

         xml2json: function(callback, r, json) {
           if (json) {
             var o;
             eval("o="+r.responseText);
             callback(o);
           } else {
           if (r.status >= 400) {
               Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL,
                   'xml2json: invalid XML document: ' +
 r.transport.responseText + " : " + r.request.url));
               return;
           }

 }}}
 [[BR]]

 3. MapGuide template deals with the error handling string, get the
 readable message by parsing <h2></h2>. [[BR]]

 {{{

 var fusionError = function(eventId, error) {
     var errorMessage = error.toString();
     var readableMessage = '';

     //Case 1: For dealing with Function: convertXML (fusion.js)
     //******************************************
     //        xml2json: function(callback, r, json) {
     //      if (json) {
     //        var o;
     //        eval("o="+r.responseText);
     //        callback(o);
     //      } else {
     //      if (r.status >= 400) {
     //          Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL,
     //              'xml2json: invalid XML document: ' +
 r.transport.responseText + " : " + r.request.url));
     //          return;
     //      }
     //******************************************
     var tagStart = '<h2>';
     var tagEnd = '</h2>';
     var indexStart = errorMessage.indexOf(tagStart);
     var indexEnd = errorMessage.indexOf(tagEnd, tagStart);
     if (indexStart != -1 && indexEnd != -1) {
         readableMessage = errorMessage.substring(indexStart +
 tagStart.length, indexEnd);
         readableMessage = readableMessage.replace(/\\n/g, '\n');
         readableMessage = readableMessage.replace(/\\t/g, '\t');
     }

 }}}

 Then a user-friendly error message pops up.

-- 
Ticket URL: <http://trac.osgeo.org/fusion/ticket/304#comment:4>
Fusion <http://trac.osgeo.org/fusion>
Fusion is a web-mapping application development framework for MapServer and MapGuide OS.


More information about the fusion-trac mailing list