Errorsys redefinition

Errorsys redefinition

Postby pawelu » Mon Oct 30, 2006 5:17 am

Antonio,

I create own errorsys procedure which may prevent for use open database or generally for terminate sleeping program process (in pocket memory in some situation exists only program process without any window and database may still open). When error handler is call program show error: "Too many recursive error handler calls". How to fix this ?

Thanks for reply
Pawel

Sample code:
Code: Select all  Expand view
#Include 'FwCe.Ch'

Function TestErr ()

   Local oWnd := Nil
   
   AppIni ()

   Define Window oWnd Title 'Test error'
   @ 100, 100 Button 'Open1' Size 60, 20 Pixel Action OpenTest ()
   @ 130, 100 Button 'Open2' Size 60, 20 Pixel Action OpenTest ()
   Activate Window oWnd
   
   DbCloseAll ()

Return .T.

Function OpenTest ()

   Local aStr := {}

   If !File ('TESTERR.DBF')
      AAdd (aStr, {'F1', 'C', 10, 0})
      DbCreate ('TESTERR', aStr)
      Use TestErr New
   Else
      Use TestErr New
   Endif
   
   MsgInfo ('Database in use')

Return .T.

// 2006-03-18 14:24:03
Function ErrorSys ()

   ErrorBlock ({|o| ShowError (o)})

Return .T.

// 2006-03-18 14:24:03
Static Function ShowError (oError)

   Local cError := ''
   Local n := 2
   Local nHn := 0

   If oError : GenCode == EG_OPEN // this generates error "Too many recursive error handler calls"
      MsgInfo ('Program process is still running !', PROGNAME)
      DbCloseAll ()
      // ProgramTask () // procedure to kill program process
      PostQuitMessage (0)
      Quit
   Endif

   cError := oError : Description

   If !Empty (oError : Operation)
      cError += Hb_OsNewLine () + oError : Operation
   Endif

   cError += Hb_OsNewLine () + 'Call history:' + Hb_OsNewLine ()

   Do While !Empty (ProcName (n))
      cError += AllTrim (ProcName (n)) + ' (' + AllTrim (Str (ProcLine (n))) + ')' + Hb_OsNewLine ()
      n ++
   Enddo

   If !File ('Error.Txt')
      nHn := FCreate ('Error.Txt')
   Else
      nHn := FOpen ('Error.Txt', 2)
      FSeek (nHn, 0, 2)
   Endif
   FWrite (nHn, DToC (Date ()) + ' ' + Time () + Hb_OsNewLine ())
   FWrite (nHn, cError)
   FWrite (nHn, Replicate ('-', 40) + Hb_OsNewLine ())
   FClose (nHn)

   MsgInfo (cError, 'Program error')

   DbCloseAll ()
   // ProgramTask () // procedure to kill program process
   PostQuitMessage (0)
   Quit

Return .T.

// system defaults
Function AppIni ()

   Request DbfCdx
   Request DbfFpt
   RddSetDefault ('DbfCdx')
   Request Hb_Lang_PL852
   Request Hb_Lang_PLWIN
   Request Hb_CodePage_PL852
   Request Hb_CodePage_PLWIN

   Set Century On
   Set Epoch To 2000
   Set Date German
   Set Deleted On
   Hb_LangSelect ('PL')
   Hb_SetCodePage ('PLWIN')

Return .T.

pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Re: Errorsys redefinition

Postby Enrico Maria Giordano » Mon Oct 30, 2006 8:00 am

Add

? oError : GenCode

at the beginning of the error handler and let me know what you get.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby pawelu » Mon Oct 30, 2006 8:19 am

Enrico,

Nothing is change. Error message still exists this same.

Pawel
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Postby Enrico Maria Giordano » Mon Oct 30, 2006 9:17 am

If you have

? oError : GenCode

just before

If oError : GenCode == EG_OPEN

then it seems that your error handler is not called.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Mon Oct 30, 2006 10:04 am

Pawel,

Try as Enrico says using

MsgInfo( oError : GenCode )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Mon Oct 30, 2006 10:06 am

Right!

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby pawelu » Mon Oct 30, 2006 10:40 am

Antonio,

Error code is show (21) but next "Too many recursive ..." message is diplay.

Pawel
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Postby Enrico Maria Giordano » Mon Oct 30, 2006 10:55 am

It seems that PROGNAME is not defined, or am I wrong?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby pawelu » Mon Oct 30, 2006 11:06 am

Enrico,

PROGNAME is defined as 'Program' (#Define PROGNAME 'Program').

Pawel
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland

Postby Antonio Linares » Mon Oct 30, 2006 11:10 am

Pawel,

Have you included the define for EG_OPEN ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby pawelu » Mon Oct 30, 2006 11:14 am

Antonio,

You're right. 'Error.Ch' must be included.
Thanks for help.

Pawel
pawelu
 
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 8 guests