FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWErrorsys()
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
FWErrorsys()
Posted: Wed Apr 03, 2024 03:50 PM
How the FWErrorsys() function works ?
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWErrorsys()
Posted: Wed Apr 03, 2024 07:54 PM

FWH procedure FWErrorSys() is identical to FWH procedure ErrorSys() that it is automatically called by Harbour.

procedure ErrorSys() invokes function ErrorBlock() to replace the default application errorBlock:

ErrorBlock( { | e | ErrorDialog( e ) } )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: FWErrorsys()
Posted: Wed Apr 03, 2024 08:26 PM

I wrote the FW Error Sys() function in which I specified my code block

Error Block( { | e | MyFunc(), Error Dialog( e ) } )

However, when compiling, I get an error - the Error Dialog() function was not found

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWErrorsys()
Posted: Wed Apr 03, 2024 09:06 PM

function ErrorDialog( e ) is static so you have to modify errsysw.prg to make it public or entirely replace FWH errsysw.prg with one of your own

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWErrorsys()
Posted: Wed Apr 03, 2024 11:16 PM
You wrote:
Code (fw): Select all Collapse
Error Block( { | e | MyFunc(), Error Dialog( e ) } )
From this, I understand that when an error occurs, you want MyFunc() should be executed first and then invoke the FWH ErrorDialog.

We can achieve this without modifying errsysw.prg
Please try this sample:
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local bFwErr

   bFwErr   := ErrorBlock()
   ErrorBlock( { |e| MyFunc( e ), Eval( bFWErr, e ) } )

   ? "Will now generate Error and see"
   ? Date() == 9

return nil

function MyFunc( e )

   MsgInfo( e:Description + CRLF + e:Operation, "MY FUNC" )
   ? "Next, you will see FWH Error Dialog"

return nil
Please just run the sample and see how your MyFunc() is exeucted first and later FWH's ErrorDialog() is executed.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWErrorsys()
Posted: Wed Apr 03, 2024 11:37 PM
In case, we want to take some action after the FWH's ErrorDialog() is executed, we can do like this:
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   SetPostErrorAction( { |cLogFile, e| MyFunc( cLogFile, e ) } )

   ? "Will now generate Error and see"
   ? Date() == 9

return nil

function MyFunc( cLogFile, e )

   ? "Sending email " + TrueName( cLogFile )

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWErrorsys()
Posted: Thu Apr 04, 2024 12:01 AM
In case we do not like FWH provided ErrorDialog and like to display our own ErrorDialog, we can do this:
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   SetErrorDialog( { |e, aStack, cErrLogText, cErrLogFile | ;
       MyErrorDialog( e, aStack, cErrLogText, cErrLogFile ) } )

   ? "Will now generate Error and see"
   ? Date() == 9

return nil

function MyErrorDialog( e, aStack, cErrLogText, cErrLogFile )

   MsgInfo( e:Description + CRLF + e:Operation + CRLF + ;
      FW_ArrayAsList( e:Args, ", " ) + CRLF + ;
      FW_ArrayAsList( aStack, CRLF ), ;
      "MY ERROR DIALOG" )

return nil
Please run the above three programs as it is and see.
We can do all the aboe without modifying the errsysw.prg
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: FWErrorsys()
Posted: Thu Apr 04, 2024 03:49 AM
Lastly,
If we do not like to use FWH's error handling and like to have our own error handler

Then at the beginning of the application, execute
Code (fw): Select all Collapse
ErrorBlock( { |e| MyErrorHandler( e ) } )
and have our own error handling module like "errsysmy.prg" with this function.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: FWErrorsys()
Posted: Thu Apr 04, 2024 08:52 AM
From this, I understand that when an error occurs, you want MyFunc() should be executed first and then invoke the FWH ErrorDialog.
Yes, that's exactly what I wanted. Thank you, Rao !

Continue the discussion