Author | Topic: WAA Error handling via prgError() | |
---|---|---|
Thomas Braun | WAA Error handling via prgError() on Fri, 24 Feb 2006 13:26:11 +0100 Hi, I'm currently doing some maintenance work for my WAA applications. So I'm trying to overload html3:prgError() - everything went OK 'til the point where prgError() returns. I do not call the parent method, but return my own html code (which currently is waa1err.htm), which according to the documentation should be OK. But all I get is: > Internal Server Error The server encountered an internal error or > misconfiguration and was unable to complete your request. > > Please contact the server administrator, tb@ellistours.com and inform > them of the time the error occurred, and anything you might have done > that may have caused the error. > > More information about this error may be available in the server error > log. and: [Fri Feb 24 13:09:50 2006] [error] [client 127.0.0.1] malformed header from script. Bad header=<html>: waa1gate.exe, referer: http://localhost/ Did anyone succeed in completely replacing prgError() with a custom version? Any idea what could cause this? Below the complete code of my own prgError() method: > Method ShopHtml:PrgError(oError, oContext) > LOCAL i, cError := "", aHost, cTimestamp > LOCAL cTemplate, cCallStack := "" > > cTimeStamp := TRANSFORM(DTOS(DATE()), "@R 9999-99-99") + " / " + TIME() > > cError += CRLF + cTimeStamp + CRLF+CRLF > cError += "Referer() : " + oContext:getReferer() + CRLF > cError += "RemoteAddr() : " + oContext:getRemoteAddr() > IF (aHost := SocketGetHostByAddr(oContext:getRemoteAddr() )) != NIL > cError += " / " + aHost[HOSTINFO_CNAME] + CRLF > ELSE > cError += CRLF > ENDIF > > cError += "RemoteBrowser(): " + oContext:getRemoteBrowser() + CRLF > cError += "RemoteEMail() : " + oContext:getRemoteEMail() + CRLF > cError += "RemoteHost() : " + oContext:getRemoteHost() + CRLF > cError += "RemoteUser() : " + oContext:getRemoteUser() + CRLF > cError += "ScriptName() : " + oContext:getScriptName() + CRLF + CRLF > > cError += XtoC(oError) + CRLF > i := 2 > DO WHILE ! Empty( ProcName(++i) ) > cError += CRLF + " " + Trim( ProcName(i) ) + "(" + LTrim( Str( ProcLine(i) ) ) + ")" > cCallStack += Trim( ProcName(i) ) + "(" + LTrim( Str( ProcLine(i) ) ) + ")<br>" > ENDDO > > ::SendMail( "Error in web application (" + cTimeStamp + ")", "", "waa@server.com", "<tb@software-braun.de>", "", "", cError ) > > ALTD() > cTemplate := MEMOREAD("WAA1ERR.HTM") > > cTemplate := STRTRAN(cTemplate, "<%var=WAA_PACKAGE%>" , ::GetVar("WAA_PACKAGE")) > cTemplate := STRTRAN(cTemplate, "<%var=WAA_FORM%>" , ::GetVar("WAA_FORM")) > cTemplate := STRTRAN(cTemplate, "<%var=ERROR_DESCRIPTION%>" , oError:description) > cTemplate := STRTRAN(cTemplate, "<%var=ERROR_OPERATION%>" , oError:operation) > cTemplate := STRTRAN(cTemplate, "<%var=ERROR_GENCODE%>" , STR(oError:gencode)) > cTemplate := STRTRAN(cTemplate, "<%var=ERROR_OSCODE%>" , STR(oError:oscode) ) > cTemplate := STRTRAN(cTemplate, "<%var=CALLSTACK%>" , cCallstack) > > RETURN cTemplate Thanks for any hint... Thomas | |
Thomas Braun | Re: WAA Error handling via prgError() on Tue, 28 Feb 2006 12:28:19 +0100 Thomas Braun wrote: > [Fri Feb 24 13:09:50 2006] [error] [client 127.0.0.1] malformed header > from script. Bad header=<html>: waa1gate.exe, referer: http://localhost/ Problem resolved! I tried google with the above error message and found several references about content-type headers... and this actually was the clue to the solution. I added the following line(s) to the waa1err.htm file: Content-Type: text/html; charset=ISO-8859-1 The IMPORTANT part is to put a single, empty line afterwards, otherwise it is not recognised as a header, but as part of the HTM content. Obviously, WAA is not adding the content-type header to the customised html code, but only to its own internal version. HTH someone else Thomas | |
Bruce Anderson | Re: WAA Error handling via prgError() on Tue, 28 Feb 2006 09:44:10 -0600 I am a bear of small brain today. When I look at the default waa1err.htm, I see this same Content-Type tag already there. Where did you "add" the lines? Alternately, couldn't you read in the default waa1err.htm as a template, do your strtran(), and write a replacement waa1err.htm back? > I added the following line(s) to the waa1err.htm file: > > Content-Type: text/html; charset=ISO-8859-1 > > The IMPORTANT part is to put a single, empty line afterwards, otherwise it > is not recognised as a header, but as part of the HTM content. > > Obviously, WAA is not adding the content-type header to the customised > html > code, but only to its own internal version. | |
Thomas Braun | Re: WAA Error handling via prgError() on Wed, 01 Mar 2006 10:22:39 +0100 Bruce Anderson wrote: > I am a bear of small brain today. When I look at the default waa1err.htm, I > see this same Content-Type tag already there. Most likely you mean this strange "meta" tag: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> which is not the same as this: Content-Type: text/html; charset=ISO-8859-1 <html> <head> <title>.... The second variant is setting a real HTTP header, not only a META tag. > Where did you "add" the lines? As you can see above, before the actual HTML content, otherwise it has no effect (or should I say "not always"... which depends on the web server and the browser), I did not check this with my production IIS server. See http://vancouver-webpages.com/META/metatags.detail.html for more details. > Alternately, couldn't you read in the default waa1err.htm as a template, do > your strtran(), and write a replacement waa1err.htm back? Ah - so WAA reads the already prepared waa1err.htm? - this is indeed a very good idea! best regards Thomas |