1 Reply Latest reply on Sep 11, 2010 6:56 AM by Fred in Orlando

    Display well formatted html error page; how to

    Fred in Orlando Level 1

      I'm using Django for my backend and mostly getting XML responses to my HttpService requests.  However when I get an error on the backend, The message in the fault event is relatively useless.  To debug I have to copy the request string from the alert window and post it in a separate browser window to see the error traceback.

       

      I'm using Django on the backend which gives a very nicely formatted error page but I cannot see that from Flex.  I would like to detect the error and open a new browser window/tab and display the "pretty" info.  Below is a snippet of what i'm doing now:

       

                  public  function AssessmentActionServiceFaultHandler(event:FaultEvent):void {
                      Alert.show("FAULT "+event.message);
                  }

       

      and I see something like this:

      getUser failed (mx.messaging.messages::ErrorMessage)#0
        body = ""
        clientId = "DirectHTTPChannel0"
        correlationId = "4451F459-39AD-F687-87A6-FCBD2AD9BC11"
        destination = ""
        extendedData = (null)
        faultCode = "Server.Error.Request"
        faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:37813/django/mds30/app/getuser/?hostport=localhost:7777&https=N&id=4451F4 59-39AD-F687-87A6-FCBD2AD9BC11"]. URL: http://localhost:7777/django/mds30/app/getuser/"
        faultString = "HTTP request error"
        headers = (Object)#1
          DSStatusCode = 0
        messageId = "F6075BBF-2CAE-0FCC-BDB7-FCBD32C34E2B"
        rootCause = (flash.events::IOErrorEvent)#2
          bubbles = false
          cancelable = false
          currentTarget = (flash.net::URLLoader)#3
            bytesLoaded = 0
            bytesTotal = 0
            data = ""
            dataFormat = "text"
          eventPhase = 2
          target = (flash.net::URLLoader)#3
          text = "Error #2032: Stream Error. URL: http://localhost:37813/django/mds30/app/getuser/?hostport=localhost:7777&https=N&id=4451F4 59-39AD-F687-87A6-FCBD2AD9BC11"
          type = "ioError"
        timestamp = 0
        timeToLive = 0

       

      ------------------while a normal web page displays something like this----------------------------------------------

       

      instance at /django/mds30/app/getuser/

      Deprecated String Exception: 'error demo'
      Request Method:GET
      Request URL:http://localhost:7777/django/mds30/app/getuser/
      Django Version:1.2.1
      Exception Type:instance
      Exception Value:
      Deprecated String Exception: 'error demo'
      Exception Location:C:\all\projects\AccMDS30Server\mds30\app\views.py in getuser,  line 87
      Python Executable:c:\alltools\python\python.exe
      Python Version:2.4.0
      Python Path:['C:\\all\\projects\\AccMDS30Server\\mds30',  'c:\\alltools\\python\\lib\\site-packages\\mysql_python-1.2.2-py2.4-win32.egg',  'c:\\alltools\\python\\lib\\site-packages\\fdfgen-0.9.1-py2.4.egg',  'C:\\all\\projects\\AccMDS30Server',  'C:\\all\\projects\\AccMDS30Server\\mds30', 'c:\\alltools\\python',  'c:\\alltools\\python\\DLLs', 'c:\\alltools\\python\\lib',  'c:\\alltools\\python\\lib\\lib-tk',  'c:\\alltools\\python\\lib\\plat-win',  'c:\\alltools\\python\\lib\\site-packages',  'C:\\Windows\\system32\\python24.zip', 'C:\\alltools\\eclipse with  PyDev']
      Server time:Fri, 10 Sep 2010 13:44:06 -0400

       

      Traceback Switch to copy-and-paste view

      • c:\alltools\python\Lib\site-packages\django\core\handlers\base.py in get_response
        1. # Apply view middleware
        2. for  middleware_method in self._view_middleware:
        3. response = middleware_method(request, callback, callback_args,  callback_kwargs)
        4. if response:
        5. return response
        6. try:
        1. response = callback(request, *callback_args, **callback_kwargs) ...
        1. except  Exception, e:
        2. # If the view raised an exception, run it through  exception
        3. # middleware, and if the exception middleware returns a
        4. #  response, use that. Otherwise, reraise the exception.
        5. for  middleware_method in self._exception_middleware:
        6. response = middleware_method(request, e)
        Variable Value
        callback
        <function getuser at  0x033C69F0>
        callback_args
        ()
        callback_kwargs
        {}
        exc_info
        ('error demo', None,  <traceback object at 0x033C0918>)
        exceptions
        <module  'django.core.exceptions' from  'c:\alltools\python\lib\site-packages\django\core\exceptions.pyc'>
        middleware_method
        <bound method  MessageMiddleware.process_request of  <django.contrib.messages.middleware.MessageMiddleware object at  0x031ED210>>
        receivers
        [(<function  _rollback_on_exception at 0x028EFB70>, None)]
        request
        <WSGIRequest GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{'sessionid': '352717811d57a59ad433e3d1e5f4f1d6'}, META:{'ALLUSERSPROFILE': 'C:\\ProgramData',  'APPDATA': 'C:\\Users\\frsells.ADVENTISTCARE\\AppData\\Roaming',  'COMMONPROGRAMFILES': 'C:\\Program Files (x86)\\Common Files',  'COMMONPROGRAMFILES(X86)': 'C:\\Program Files (x86)\\Common Files',  'COMMONPROGRAMW6432': 'C:\\Program Files\\Common Files',  'COMPUTERNAME': 'NB-FRSELLS',  'COMSPEC': 'C:\\Windows\\system32\\cmd.exe',  'CONTENT_LENGTH': '',  'CONTENT_TYPE': 'text/plain',  'CVSROOT': ':pserver:frsells@acccvs.sunbelt.org:/cvs',  'DJANGO_SETTINGS_MODULE': 'mds30.settings',  'FP_NO_HOST_CHECK': 'NO',  'GATEWAY_INTERFACE': 'CGI/1.1',  'HOMEDRIVE': 'C:',  'HOMEPATH': '\\Users\\frsells.ADVENTISTCARE',  'HTTP_ACCEPT':  'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',  'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',  'HTTP_ACCEPT_ENCODING': 'gzip,deflate',  'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',  'HTTP_CACHE_CONTROL': 'max-age=0',  'HTTP_CONNECTION': 'keep-alive',  'HTTP_COOKIE': 'sessionid=352717811d57a59ad433e3d1e5f4f1d6',  'HTTP_HOST': 'localhost:7777',  'HTTP_KEEP_ALIVE': '115',  'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;  rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6',  'JAVA_HOME': 'c:\\alltools\\jdk5',  'LOCALAPPDATA': 'C:\\Users\\frsells.ADVENTISTCARE\\AppData\\Local',  'LOGONSERVER': '\\\\ACCVDC03',  'NUMBER_OF_PROCESSORS': '4',  'OS': 'Windows_NT',  'PATH':  'c:/alltools/jdk5/bin/../jre/bin/client;c:/alltools/jdk5/bin/../jre/bin;C:\\Program  Files  (x86)\\NetworkSimplicity\\ssh;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wb em;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program  Files\\Intel\\DMIX;C:\\Program Files (x86)\\NTRU Cryptosystems\\NTRU  TCG Software Stack\\bin\\;C:\\Program Files\\NTRU Cryptosystems\\NTRU  TCG Software Stack\\bin\\;C:\\Program Files\\Wave Systems  Corp\\Gemalto\\Access Client\\v5\\;C:\\Program Files (x86)\\Common  Files\\Roxio Shared\\DLLShared\\;C:\\Program Files (x86)\\Common  Files\\Roxio  Shared\\10.0\\DLLShared\\;c:\\alltools\\jdk5\\bin;c:\\alltools\\python;c:\\alltools\\pyth on\\scripts;c:\\alltools\\ant;c:\\alltools\\bin;C:\\Program  Files\\MySQL\\MySQL Server  5.0\\bin;C:\\all\\scripts;C:\\alltools\\ant\\bin',  'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',  'PATH_INFO': u'/django/mds30/app/getuser/',  'PROCESSOR_ARCHITECTURE': 'x86',  'PROCESSOR_ARCHITEW6432': 'AMD64',  'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 23 Stepping 10,  GenuineIntel',  'PROCESSOR_LEVEL': '6',  'PROCESSOR_REVISION': '170a',  'PROGRAMDATA': 'C:\\ProgramData',  'PROGRAMFILES': 'C:\\Program Files (x86)',  'PROGRAMFILES(X86)': 'C:\\Program Files (x86)',  'PROGRAMW6432': 'C:\\Program Files',  'PROMPT': '$P$G',  'PSMODULEPATH':  'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\',  'PUBLIC': 'C:\\Users\\Public',  'PYDEV_COMPLETER_PYTHONPATH': 'C:\\alltools\\eclipse with  PyDev\\plugins\\org.python.pydev_1.6.1.2010080312\\PySrc',  'PYDEV_CONSOLE_ENCODING': 'Cp1252',  'PYTHONIOENCODING': 'Cp1252',  'PYTHONPATH': 'C:\\alltools\\eclipse with  PyDev\\plugins\\org.python.pydev_1.6.1.2010080312\\PySrc\\pydev_sitecustomize;C:\\all\\pr ojects\\AccMDS30Server;C:\\all\\projects\\AccMDS30Server\\mds30;c:\\alltools\\python;c:\\a lltools\\python\\DLLs;c:\\alltools\\python\\lib;c:\\alltools\\python\\lib\\lib-tk;c:\\allt ools\\python\\lib\\plat-win;c:\\alltools\\python\\lib\\site-packages',   'QUERY_STRING': '',  'REMOTE_ADDR': '127.0.0.1',  'REMOTE_HOST': '',  'REQUEST_METHOD': 'GET',  'ROXIOCENTRAL': 'C:\\Program Files (x86)\\Common Files\\Roxio  Shared\\10.0\\Roxio Central36\\',  'RUN_MAIN': 'true',  'SCRIPT_NAME': u'',  'SERVER_NAME': 'NB-FRSELLS.adventistcare.net',  'SERVER_PORT': '7777',  'SERVER_PROTOCOL': 'HTTP/1.1',  'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.4',  'SESSIONNAME': 'Console',  'SYSTEMDRIVE': 'C:',  'SYSTEMROOT': 'C:\\Windows',  'TEMP': 'C:\\Users\\FRSELL~1.ADV\\AppData\\Local\\Temp',  'TMP': 'C:\\Users\\FRSELL~1.ADV\\AppData\\Local\\Temp',  'USERDNSDOMAIN': 'ADVENTISTCARE.NET',  'USERDOMAIN': 'ADVENTISTCARE',  'USERNAME': 'frsells',  'USERPROFILE': 'C:\\Users\\frsells.ADVENTISTCARE',  'VS100COMNTOOLS': 'C:\\Program Files (x86)\\Microsoft Visual Studio  10.0\\Common7\\Tools\\',  'WINDIR': 'C:\\Windows',  'wsgi.errors': <open file '<stderr>', mode 'w' at  0x0037E0B0>,  'wsgi.file_wrapper': <class  'django.core.servers.basehttp.FileWrapper'>,  'wsgi.input': <socket._fileobject object at 0x02A8ECE0>,  'wsgi.multiprocess': False,  'wsgi.multithread': True,  'wsgi.run_once': False,  'wsgi.url_scheme': 'http',  'wsgi.version': (1, 0)}>
        resolver
        <RegexURLResolver  mds30.urls (None:None) ^/>
        response
        None
        self
        <django.core.handlers.wsgi.WSGIHandler  object at 0x028C7590>
        settings
        <django.conf.LazySettings  object at 0x024F6710>
        urlconf
        'mds30.urls'
        urlresolvers
        <module  'django.core.urlresolvers' from  'c:\alltools\python\lib\site-packages\django\core\urlresolvers.pyc'>
      • C:\all\projects\AccMDS30Server\mds30\app\views.py in getuser
        1. temp += '<p>GET.META["REMOTE_ADDR"]=' +  str(request.META['REMOTE_ADDR'])
        2. #temp += '<p>GET.META["USERNAME"]=' +  str(request.META['USERNAME'])
        3. #temp += '<p>GET.META["SESSIONNAME"]=' +  str(request.META['SESSIONNAME'])
        4. temp += '<p>GET.META=' + str(request.META)
        5. return  HttpResponse("Hello, You are using the MDS 3.0 web service from %s" %  temp)
        6. def getuser(request,  *args, **kwargs):
        1. raise 'error demo' ...
        1. sessionid =  getACCSessionId(request)
        2. user = security.getUser(sessionid)
        3. if user==None:
        4. values =  {'Error':sessionid, 'user':str(user)}
        5. else:
        6. values =  user.__dict__.copy()
        Variable Value
        args
        ()
        kwargs
        {}
        request
        <WSGIRequest GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{'sessionid': '352717811d57a59ad433e3d1e5f4f1d6'}, META:{'ALLUSERSPROFILE': 'C:\\ProgramData',  'APPDATA': 'C:\\Users\\frsells.ADVENTISTCARE\\AppData\\Roaming',  'COMMONPROGRAMFILES': 'C:\\Program Files (x86)\\Common Files',  'COMMONPROGRAMFILES(X86)': 'C:\\Program Files (x86)\\Common Files',  'COMMONPROGRAMW6432': 'C:\\Program Files\\Common Files',  'COMPUTERNAME': 'NB-FRSELLS',  'COMSPEC': 'C:\\Windows\\system32\\cmd.exe',  'CONTENT_LENGTH': '',  'CONTENT_TYPE': 'text/plain',  'CVSROOT': ':pserver:frsells@acccvs.sunbelt.org:/cvs',  'DJANGO_SETTINGS_MODULE': 'mds30.settings',  'FP_NO_HOST_CHECK': 'NO',  'GATEWAY_INTERFACE': 'CGI/1.1',  'HOMEDRIVE': 'C:',  'HOMEPATH': '\\Users\\frsells.ADVENTISTCARE',  'HTTP_ACCEPT':  'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',  'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',  'HTTP_ACCEPT_ENCODING': 'gzip,deflate',  'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',  'HTTP_CACHE_CONTROL': 'max-age=0',  'HTTP_CONNECTION': 'keep-alive',  'HTTP_COOKIE': 'sessionid=352717811d57a59ad433e3d1e5f4f1d6',  'HTTP_HOST': 'localhost:7777',  'HTTP_KEEP_ALIVE': '115',  'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;  rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6',  'JAVA_HOME': 'c:\\alltools\\jdk5',  'LOCALAPPDATA': 'C:\\Users\\frsells.ADVENTISTCARE\\AppData\\Local',  'LOGONSERVER': '\\\\ACCVDC03',  'NUMBER_OF_PROCESSORS': '4',  'OS': 'Windows_NT',  'PATH':  'c:/alltools/jdk5/bin/../jre/bin/client;c:/alltools/jdk5/bin/../jre/bin;C:\\Program  Files  (x86)\\NetworkSimplicity\\ssh;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wb em;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program  Files\\Intel\\DMIX;C:\\Program Files (x86)\\NTRU Cryptosystems\\NTRU  TCG Software Stack\\bin\\;C:\\Program Files\\NTRU Cryptosystems\\NTRU  TCG Software Stack\\bin\\;C:\\Program Files\\Wave Systems  Corp\\Gemalto\\Access Client\\v5\\;C:\\Program Files (x86)\\Common  Files\\Roxio Shared\\DLLShared\\;C:\\Program Files (x86)\\Common  Files\\Roxio  Shared\\10.0\\DLLShared\\;c:\\alltools\\jdk5\\bin;c:\\alltools\\python;c:\\alltools\\pyth on\\scripts;c:\\alltools\\ant;c:\\alltools\\bin;C:\\Program  Files\\MySQL\\MySQL Server  5.0\\bin;C:\\all\\scripts;C:\\alltools\\ant\\bin',  'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',  'PATH_INFO': u'/django/mds30/app/getuser/',  'PROCESSOR_ARCHITECTURE': 'x86',  'PROCESSOR_ARCHITEW6432': 'AMD64',  'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 23 Stepping 10,  GenuineIntel',  'PROCESSOR_LEVEL': '6',  'PROCESSOR_REVISION': '170a',  'PROGRAMDATA': 'C:\\ProgramData',  'PROGRAMFILES': 'C:\\Program Files (x86)',  'PROGRAMFILES(X86)': 'C:\\Program Files (x86)',  'PROGRAMW6432': 'C:\\Program Files',  'PROMPT': '$P$G',  'PSMODULEPATH':  'C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\',  'PUBLIC': 'C:\\Users\\Public',  'PYDEV_COMPLETER_PYTHONPATH': 'C:\\alltools\\eclipse with  PyDev\\plugins\\org.python.pydev_1.6.1.2010080312\\PySrc',  'PYDEV_CONSOLE_ENCODING': 'Cp1252',  'PYTHONIOENCODING': 'Cp1252',  'PYTHONPATH': 'C:\\alltools\\eclipse with  PyDev\\plugins\\org.python.pydev_1.6.1.2010080312\\PySrc\\pydev_sitecustomize;C:\\all\\pr ojects\\AccMDS30Server;C:\\all\\projects\\AccMDS30Server\\mds30;c:\\alltools\\python;c:\\a lltools\\python\\DLLs;c:\\alltools\\python\\lib;c:\\alltools\\python\\lib\\lib-tk;c:\\allt ools\\python\\lib\\plat-win;c:\\alltools\\python\\lib\\site-packages',   'QUERY_STRING': '',  'REMOTE_ADDR': '127.0.0.1',  'REMOTE_HOST': '',  'REQUEST_METHOD': 'GET',  'ROXIOCENTRAL': 'C:\\Program Files (x86)\\Common Files\\Roxio  Shared\\10.0\\Roxio Central36\\',  'RUN_MAIN': 'true',  'SCRIPT_NAME': u'',  'SERVER_NAME': 'NB-FRSELLS.adventistcare.net',  'SERVER_PORT': '7777',  'SERVER_PROTOCOL': 'HTTP/1.1',  'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.4',  'SESSIONNAME': 'Console',  'SYSTEMDRIVE': 'C:',  'SYSTEMROOT': 'C:\\Windows',  'TEMP': 'C:\\Users\\FRSELL~1.ADV\\AppData\\Local\\Temp',  'TMP': 'C:\\Users\\FRSELL~1.ADV\\AppData\\Local\\Temp',  'USERDNSDOMAIN': 'ADVENTISTCARE.NET',  'USERDOMAIN': 'ADVENTISTCARE',  'USERNAME': 'frsells',  'USERPROFILE': 'C:\\Users\\frsells.ADVENTISTCARE',  'VS100COMNTOOLS': 'C:\\Program Files (x86)\\Microsoft Visual Studio  10.0\\Common7\\Tools\\',  'WINDIR': 'C:\\Windows',  'wsgi.errors': <open file '<stderr>', mode 'w' at  0x0037E0B0>,  'wsgi.file_wrapper': <class  'django.core.servers.basehttp.FileWrapper'>,  'wsgi.input': <socket._fileobject object at 0x02A8ECE0>,  'wsgi.multiprocess': False,  'wsgi.multithread': True,  'wsgi.run_once': False,  'wsgi.url_scheme': 'http',  'wsgi.version': (1, 0)}>

       

       

      Request information

       

      GET

      No GET data

      POST

      No POST data

      FILES

      No FILES data

      COOKIES

      Variable Value
      sessionid
      '352717811d57a59ad433e3d1e5f4f1d6'

      META

        • 1. Re: Display well formatted html error page; how to
          Fred in Orlando Level 1

          I came up with an ugly solution.  I save the last url and then resend it if a fault is detected.  probably not a good thing in production, but I'm still developing.  here's the code

           

              public  function AssessmentActionServiceFaultHandler(event:FaultEvent):void {
                          Globals.log("command FAILED "+event.message);   
                          Globals.hideBusyDialog();
                          //Alert.show("FAULT "+event.message);
                          navigateToURL(new URLRequest( LastURL), "_blank" );

           

                      }