[mapguide-trac] #1083: Report meaningful error message without changing MapAgent status text

MapGuide Open Source trac_mapguide at osgeo.org
Wed Sep 2 05:48:30 EDT 2009


#1083: Report meaningful error message without changing MapAgent status text
----------------------------+-----------------------------------------------
   Reporter:  christinebao  |       Owner:  Chris Claydon
       Type:  defect        |      Status:  new          
   Priority:  medium        |   Milestone:  2.2          
  Component:  Fusion        |     Version:  2.0.2        
   Severity:  major         |    Keywords:               
External_id:  1246885       |  
----------------------------+-----------------------------------------------
 '''Cause:'''
 [[BR]]
 RFC http://trac.osgeo.org/mapguide/wiki/MapGuideRfc66 (Prevent session
 timeout, and give better error messages) requires to show meaningful error
 message if server exception happens. Previously the error message
 displayed exception type such as [[BR]]
 {{{
 FATAL: xml2json: invalid XML document: '''MgConnectionFailedException''' :
 http://127.0.0.1/mapguide2010/mapagent/mapagent.fcgi?version=1.0.0&locale=en&clientagent=Fusion%20Viewer&operation=QUERYMAPFEATURES&session=
 40d3e074-3ee5-102c-8000-
 005056c00008_en_7F0000010AFC0AFB0AFA&mapname=Sheboygan4a3b609791c82&geometry=POLYGON((-87.730254250931%2043.73763292302%2C%
 20-87.730254250931%2043.737069942268%2C%20-
 87.729691270179%2043.737069942268%2C%20-
 87.729691270179%2043.73763292302%2C%20-
 87.730254250931%2043.73763292302))&maxFeatures=1&persist=0&selectionVariant=INTERSECTS&layerNames=&layerAttributeFilter=5
 type=0
 }}}

 However this is not user-friendly for end users. A localizable exception
 message is preferred rather than class name. As the content of error
 message is from fusion 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.statusText'''
 + " : " + r.request.url));
                     return;
                 }
 }}}[[BR]]
 A solution is to set exception message instead of exception class name as
 XmlHttpRequest (r) status text. Take CgiAgent for example, the code is
 changed to follow (please pay attention to status text, which is set as
 shortError, equal exception message):[[BR]]
 {{{
 void CgiResponseHandler::SendError(MgException* e)
 {
     MG_TRY()
     STRING shortError = e->GetMessage();
     STRING longError = e->GetDetails();
     STRING statusMessage = e->GetClassName();

     //TODO: Use a string resource for html error text format
     printf(MapAgentStrings::StatusHeader, 559,
 MG_WCHAR_TO_CHAR(shortError));
     printf(MapAgentStrings::ContentTypeHeader, MapAgentStrings::TextHtml,
 MapAgentStrings::Utf8Text);
     printf("\r\n"
         "<html>\n<head>\n"
         "<title>%s</title>\n"
         "<meta http-equiv=\"Content-Type\" content=\"text/html;
 charset=utf-8\">\n"
         "</head>\n"
         "<body>\n<h2>%s</h2>\n%s\n</body>\n</html>\n",
         MG_WCHAR_TO_CHAR(statusMessage),
         MG_WCHAR_TO_CHAR(shortError),
         MG_WCHAR_TO_CHAR(longError));

     DumpMessage(MG_WCHAR_TO_CHAR(longError));

     MG_CATCH(L"CgiResponseHandler.SendError")
 }
 }}}

 '''Problem:'''[[BR]]
 This solution works for RFC requirement, however it brings risk for other
 applications which depend on checking status text. [[BR]]
 One case is Web Tier unit test, which creates scenerios to throw server
 exception and verify them by status text. After changing the MapAgent
 code, all the related test cases fail.[[BR]]
 Another case is from Autodesk QA, that Studio has a code as below:[[BR]]
 {{{
 MgDev\Common\Gis\Site\SiteManager.cs(400)
                         if (we.Message.Contains("(559)")) //NOXLATE
                             if
 (we.Message.Contains("MgConnectionFailedException"))
                                 return ConnectionStatus.UnreachableServer;

 }}}
 [[BR]]
 There could be more cases potentially fail because of MapAgent change.

 '''Solution:'''[[BR]]
 Based on the defects reporting, a solution is needed to show meaningful
 error message without changing MapAgent status text. This is possible.
 When looking at the content of MapAgent response handler, it's found that
 all the information (exception class name, exception message) are
 formatted as an HTML content. And this can be got in fusion by
 r.transport.responseText.[[BR]]
 So a solution is:[[BR]]
 1. Rollback MapAgent code, exception class name is still be used as status
 text.[[BR]]
 2. Fusion returns r.transport.responseText instead of r.statusText in
 error handler.[[BR]]
 3. MapGuide templates parse r.transport.responseText to get meaningful
 exception message and display.[[BR]]

-- 
Ticket URL: <https://trac.osgeo.org/mapguide/ticket/1083>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list