Errorsys redefinition

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

Errorsys redefinition

Post by pawelu »

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

#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.

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

Re: Errorsys redefinition

Post by Enrico Maria Giordano »

Add

? oError : GenCode

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

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

Post by pawelu »

Enrico,

Nothing is change. Error message still exists this same.

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

Post by Enrico Maria Giordano »

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
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Pawel,

Try as Enrico says using

MsgInfo( oError : GenCode )
regards, saludos

Antonio Linares
www.fivetechsoft.com
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

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
Contact:

Post by pawelu »

Enrico,

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

Pawel
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Pawel,

Have you included the define for EG_OPEN ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

Antonio,

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

Pawel
Post Reply