FWErrorsys()

FWErrorsys()

Postby Natter » Wed Apr 03, 2024 3:50 pm

How the FWErrorsys() function works ?
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: FWErrorsys()

Postby Antonio Linares » Wed Apr 03, 2024 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWErrorsys()

Postby Natter » Wed Apr 03, 2024 8: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
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: FWErrorsys()

Postby Antonio Linares » Wed Apr 03, 2024 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWErrorsys()

Postby nageswaragunupudi » Wed Apr 03, 2024 11:16 pm

You wrote:
Code: Select all  Expand view  RUN
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: Select all  Expand view  RUN
#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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWErrorsys()

Postby nageswaragunupudi » 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: Select all  Expand view  RUN
#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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWErrorsys()

Postby nageswaragunupudi » 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: Select all  Expand view  RUN
#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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWErrorsys()

Postby nageswaragunupudi » Thu Apr 04, 2024 3: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: Select all  Expand view  RUN
ErrorBlock( { |e| MyErrorHandler( e ) } )


and have our own error handling module like "errsysmy.prg" with this function.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWErrorsys()

Postby Natter » Thu Apr 04, 2024 8: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 !
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 44 guests