FWErrorsys()
- Antonio Linares
- Site Admin
- Posts: 42393
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 9 times
- Been thanked: 41 times
- Contact:
Re: FWErrorsys()
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 ) } )
procedure ErrorSys() invokes function ErrorBlock() to replace the default application errorBlock:
ErrorBlock( { | e | ErrorDialog( e ) } )
Re: FWErrorsys()
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
Error Block( { | e | MyFunc(), Error Dialog( e ) } )
However, when compiling, I get an error - the Error Dialog() function was not found
- Antonio Linares
- Site Admin
- Posts: 42393
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 9 times
- Been thanked: 41 times
- Contact:
Re: FWErrorsys()
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
- nageswaragunupudi
- Posts: 10701
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 3 times
- Contact:
Re: FWErrorsys()
You wrote:
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:
Please just run the sample and see how your MyFunc() is exeucted first and later FWH's ErrorDialog() is executed.
Code: Select all | Expand
Error Block( { | e | MyFunc(), Error Dialog( e ) } )
We can achieve this without modifying errsysw.prg
Please try this sample:
Code: Select all | Expand
#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
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10701
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 3 times
- Contact:
Re: FWErrorsys()
In case, we want to take some action after the FWH's ErrorDialog() is executed, we can do like this:
Code: Select all | Expand
#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
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10701
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 3 times
- Contact:
Re: FWErrorsys()
In case we do not like FWH provided ErrorDialog and like to display our own ErrorDialog, we can do this:
Please run the above three programs as it is and see.
We can do all the aboe without modifying the errsysw.prg
Code: Select all | Expand
#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
We can do all the aboe without modifying the errsysw.prg
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10701
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 3 times
- Contact:
Re: FWErrorsys()
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
and have our own error handling module like "errsysmy.prg" with this function.
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
ErrorBlock( { |e| MyErrorHandler( e ) } )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: FWErrorsys()
Yes, that's exactly what I wanted. Thank you, Rao !From this, I understand that when an error occurs, you want MyFunc() should be executed first and then invoke the FWH ErrorDialog.