Alaska Software Inc. - Custom error handling in WAA
Username: Password:
AuthorTopic: Custom error handling in WAA
Marcin StryjekCustom error handling in WAA
on Fri, 25 Nov 2005 10:46:53 +0100
Hi all
I can't set my custom error handler in WAA package dll. I desperately tried 
to set my own error handler in many ways:
1. Using ErrorBlock() in registered WAA function to make sure it's correctly 
set when request   is   processsed.
2. Using ErrorBlock() in my package DLL init procedure
3. In my other functions called before package dll is loaded by WAA Server.
4. I've also tried to set my own error handler in the simpliest of Alaska's 
WAA samples "MYFIRST" similar way. With no success.

Calling ErrorBlock({|o|MyStandardEH(o)})  function doesn't change error 
handler and returns standard {|o|break(o)}. I'm desperately looking for ANY 
suggestion what do I do wrong.

TIA
Marcin Stryjek
I'm user of XBase++ 1.9.320
Phil Ide
Re: Custom error handling in WAA
on Fri, 25 Nov 2005 12:56:59 +0000
Marcin,

> I can't set my custom error handler in WAA package dll. I desperately tried 
> to set my own error handler in many ways:

Don't panic. I've been doing this for nearly 4 years, so can assure you it
is possible.

Here's the code I use:

errorHandler := ErrorBlock( {|o| CNError(o) } )

My form-functions look like this:


Function MyFormFunc( oHtml, oContext )
   if SessionBegin( oHtml, oContext )
       do something
   endif
   SessionEnd( oHtml, oContext )
   return TRUE

In the Session begin, I save the current error handler and set my own.  In
the SessionEnd, I reset the old error handler.

Incidentally, in my own error handler I record the error to a special log,
send myself an email, then call the original error handler.

If this doesn't work for you, then something is going badly wrong, so
seeing an example of a form-function would be helpful.

BTW, it isn't necessary to register a form-function unless you want to see
this displayed in the WAA console (or through something like WaaRC).

Regards,

Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

Of all the things I've lost, I miss my mind the least.
Marcin StryjekRe: Custom error handling in WAA
on Mon, 28 Nov 2005 08:50:46 +0100
Uzytkownik "Phil Ide" <phil@xodc.org.uk> napisal w wiadomosci 
news:1of3f3wfdqdl8$.dlg@xodc.org.uk...
> Marcin,
>
>> I can't set my custom error handler in WAA package dll. I desperately 
>> tried
>> to set my own error handler in many ways:
>
> Don't panic. I've been doing this for nearly 4 years, so can assure you it
> is possible.
>
> Here's the code I use:
>
> errorHandler := ErrorBlock( {|o| CNError(o) } )
>
> My form-functions look like this:
>
>
> Function MyFormFunc( oHtml, oContext )
>   if SessionBegin( oHtml, oContext )
>       do something
>   endif
>   SessionEnd( oHtml, oContext )
>   return TRUE

>
> In the Session begin, I save the current error handler and set my own.  In
> the SessionEnd, I reset the old error handler.
>
> Incidentally, in my own error handler I record the error to a special log,
> send myself an email, then call the original error handler.
>
> If this doesn't work for you, then something is going badly wrong, so
> seeing an example of a form-function would be helpful.
>
> BTW, it isn't necessary to register a form-function unless you want to see
> this displayed in the WAA console (or through something like WaaRC).
>
> Regards,
> -- 
> Phil Ide
>
> *******************************************
> *   Xbase++ FAQ, Libraries and Sources:   *
> *   goto: http://www.idep.org.uk/xbase    *
> * --------------------------------------- *
> * www.xodc.org.uk - openSource Dev-Center *
> *******************************************
>
> Of all the things I've lost, I miss my mind the least.

Hi again
I do it the same way as You do, but still I can't set my error handler. Here 
is source of my
function. Could You please look at it? It's not a mainstream WAA 
application, it's our way to make
legacy clipper application  data (screens, browsers, menus etc) accessible 
from web. The only registered
function is iForm()

Regards,
Marcin Stryjek


*****************************************************************************
* Funkcja kt?ra wysya wygenerowany kod HTML przeglAdarce
*****************************************************************************
Function iForm(oHTML,oContext)  Parametry wywoania tej funkcji sA 
wymagane
                                przez Web Application Adaptor
local nPowtorz:=3    Ile razy powarza? wykonanie lAdania w przypadku
                     bdu.
Local _Ret
Local lCzyKoniec:=.f.
Local oError
Local nI
Local sHtml:=""
Local sThread
Local sNazZmien

Private sCargo         Zmienna na "cargo" przekazane od egzekutora via 
strona internetowa
Private sQueueIn       Nazwa kolejki wchodzAcej
Private sQueueOut      Nazwa kolejki wychodzAcej
Private iMsNRUZYTK     Numer ulytkownika
Private iMsNr_Zad      Numer zadania dla egzekutora
Private tmpvalue:=""
Private Oper, iMsKom
Private sTekstStrony:=''  Tekst strony przekazywany z gbi funkcji
Private sRecId            Identyfikator rekordu pobrany z browsera
Private _EZ_JobDef:={}    Dziki temu EZ_AddJob() nie bdzie zakada tej
                          tablicy jako public wic odrbne wAtki nie
                          bdA wpyway na siebie.

 To co ponilej dotyczy obliczania statystyki
Private nTime:=Seconds()  Czas wykonania lAdania
Private nErrCount:=0      Liczba bd?w
Private nLoginCount:=0    Liczba logowa
Private sTestErr:=""

 Zadeklarowanie wasnej obsugi bd?w i zapamitanie
 domylnej funkcji obsugi na zmiennej, leby po obsudze
 lAdania przywr?wci? standardowA alaskowo obsug
__DefErrorSys:=ErrorBlock( {|o| ErrorSrv(o)} )

If Type("sWatki")="U"
    Public sWatki:=""
EndIf

 Tu deklaracje zmiennych kt?re w normalnym ukadzie sA publiczne
 a w ukadzie wielowAtkowym jul takie by? nie mogA z powodu
 interferencji midzy wAtkami
Private ___SepTok,___SkpTok,___NumTok,___AktTok
Private __BA_FILE:=Array(256)

sThread:=AllTrim(Str(ThreadId()))
If !","+sThread+","$sWatki+","
    sWatki:=sWatki+","+sThread
    __OpenSysTables()
Else
     Odtwarzenie __BA_FILE ze zmiennej publicznej
    sNazZmien:="__BA_FILE"+sThread
    For ni:=1 to 256
        __BA_FILE[nI]:=&(sNazZmien)[nI]
    next
EndIf

 Wykonanie lAdania internetowego. Jeleli wystApi bAd to
 pr?buj powt?rzy? to tyle razy na ile wskazuje zmienna nPowtorz
nI:=nPowtorz
While !lCzyKoniec
    Begin Sequence
         Tutaj ptla odpowiadajAca na lAdanie internetowe

        _Ret:=__ProcessRequest(oHtml, oContext)

        lCzyKoniec:=.t.
    Recover using oError
        //??? ZAPISYWANIE PLIKU *.ERW Z PRrB DIAGNOZY
        __PoNieudanejProbie()
         Nie udao si uzyska? poprawnej odpowiedzi. Bd pr?bowa
         nPowtorz razy. Dopiero kiedy wykonanie nPowtorz'tego lAdania
         zakonczy si fiaskiem wyswietl komunikat.
        nI:=nI--
        nErrCount:=nErrCount++
        If nI<=0
            lCzyKoniec:=.t.

            sHtml:=i_Header()
            sHtml:=sHtml+i_FPyt("Wykonanie polecenia nie powiodo 
si."+CRLF+;
                                "SPRrBUJ PONOWNIE"+CRLF+;
                                "Gdyby problem si konsekwentnie powtarza, 
powiadom administratora.",5,.t.)
            sHtml:=sHtml+i_Footer()
            _ret:=oHtml:Put(sHtml)
        EndIf

    End Sequence
EndDo


 Zapamitanie __BA_FILE na zmiennej publicznej
sNazZmien:="__BA_FILE"+sThread
Oblicz(sNazZmien,"Array(256)")
For ni:=1 to 256
    &(sNazZmien)[nI]:=__BA_FILE[nI]
next

 Wypenianie danych dotyczAcych statystyki
__Statystyka()

 Tutaj przywracam standardowA alaskowA procedur obsugi
ErrorBlock(__DefErrorSys)

return _Ret

******************************************************************************
* Wasna obsuga bd?w
******************************************************************************
function Errorsrv(o)  Wasna obsuga bd?w
local _Cos

_cos:=StandardEH(o)

return _Cos
Phil Ide
Re: Custom error handling in WAA
on Mon, 28 Nov 2005 10:26:24 +0000
Marcin,

> I do it the same way as You do, but still I can't set my error handler. Here 
> is source of my
> function. Could You please look at it? It's not a mainstream WAA 
> application, it's our way to make
> legacy clipper application  data (screens, browsers, menus etc) accessible 
> from web. The only registered
> function is iForm()

Well, it looks good to me - except you are calling StandardEH().  I assume
you have modified StandardEH() to do the tuff you want, and linked it to
your package DLL.

> function Errorsrv(o)  Wˆasna obsˆuga bˆ©d?w
> local _Cos
> 
> _cos:=StandardEH(o)
> 
> return _Cos

I would hazard a guess that the WAA executable contains a copy of
StandardEH(), and this is the one that gets called rather than your
version.

Try renaming it to something else.

Regards,

Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

ILLITERATE? Write for a free brochure...