Problems using error object
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Problems using error object
I have the following constructi:
bSaveErrorBlock := ErrorBlock( {|e| Break(e) } )
BEGIN SEQUENCE
DO WHILE !EOF()
SOME CODE
SKIP
ENDDO
RECOVER USING oError
WTF oError pause
wtf('Arguments: '+dc_xtoc(oError:arguments)) pause
wtf('Cargo: '+dc_xtoc(oError:arguments)) pause
wtf('Error description: '+dc_xtoc(oError:description)) pause
wtf('Gencode: '+dc_xtoc(oError:gencode)) pause
wtf('Operation: '+dc_xtoc(oError:operation)) pause
wtf('OSCode: '+dc_xtoc(oError:oscode)) pause
LB_Warning({'Arguments: '+dc_xtoc(oError:arguments), ;
'Cargo: '+dc_xtoc(oError:arguments), ;
'Error description: '+dc_xtoc(oError:description), ;
'Gencode: '+dc_xtoc(oError:gencode), ;
'Operation: '+dc_xtoc(oError:operation), ;
'OSCode: '+dc_xtoc(oError:oscode)}, ;
'Error Information')
lOK := .F.
ErrorBlock(bSaveErrorBlock)
END SEQUENCE
The WTF oError pause pauses and lets me browse the error object and I can see the instance variable.
However, when using WTF or LB_Warning (front-end to dc_msgbox()), it does not display anything. What do I need to do in order to display the error object attributes via a user popup or wtf.
Cliff
bSaveErrorBlock := ErrorBlock( {|e| Break(e) } )
BEGIN SEQUENCE
DO WHILE !EOF()
SOME CODE
SKIP
ENDDO
RECOVER USING oError
WTF oError pause
wtf('Arguments: '+dc_xtoc(oError:arguments)) pause
wtf('Cargo: '+dc_xtoc(oError:arguments)) pause
wtf('Error description: '+dc_xtoc(oError:description)) pause
wtf('Gencode: '+dc_xtoc(oError:gencode)) pause
wtf('Operation: '+dc_xtoc(oError:operation)) pause
wtf('OSCode: '+dc_xtoc(oError:oscode)) pause
LB_Warning({'Arguments: '+dc_xtoc(oError:arguments), ;
'Cargo: '+dc_xtoc(oError:arguments), ;
'Error description: '+dc_xtoc(oError:description), ;
'Gencode: '+dc_xtoc(oError:gencode), ;
'Operation: '+dc_xtoc(oError:operation), ;
'OSCode: '+dc_xtoc(oError:oscode)}, ;
'Error Information')
lOK := .F.
ErrorBlock(bSaveErrorBlock)
END SEQUENCE
The WTF oError pause pauses and lets me browse the error object and I can see the instance variable.
However, when using WTF or LB_Warning (front-end to dc_msgbox()), it does not display anything. What do I need to do in order to display the error object attributes via a user popup or wtf.
Cliff
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Problems using error object
My error. the instance variable is args, not arguments.
Thus I generated an error inside my recover using statements.
Cliff
Thus I generated an error inside my recover using statements.
Cliff
Re: Problems using error object
That was my first guess.Thus I generated an error inside my recover using statements.
The eXpress train is coming - and it has more cars.
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Problems using error object
That was correct.
But I am having trouble with the call stack. It geneates the line of the lb_warning, then the line calling the function. How do I get the line causing the error, which is a few lines above the recover using. I just forced an assignment error to test. I see the error line in the regular temp.err log for normal handling but not withing my custom handler.
But I am having trouble with the call stack. It geneates the line of the lb_warning, then the line calling the function. How do I get the line causing the error, which is a few lines above the recover using. I just forced an assignment error to test. I see the error line in the regular temp.err log for normal handling but not withing my custom handler.
Re: Problems using error object
You have to walk through the stack in a for..next loop:How do I get the line causing the error,
FOR i := 1 to 10
wtf Procname(i), ProcLine(i)
NEXT
The eXpress train is coming - and it has more cars.
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Problems using error object
That is what I am doing, but in the custom handler all I get it the line displaying the error object info as procline(0), then procline(1), is the calling function, but not the error line that caused the break(e) to be excecuted and then the RECOVER USING. How do I get the error line.
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Problems using error object
This is what I get. First line is the display of the error object. 2nd line is the line calling the function I am in, PRCOMMADEL(). The error line is not there.
Re: Problems using error object
Look at Alaska's errorsys.prg. It may help you.
The eXpress train is coming - and it has more cars.
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Problems using error object
I did and tried using their code exactly. It appears that when you use a customer error object, it affects the stack. Must have to do something with the recover using, but the error object does not have a variable for the error line number. They check for a call stack method existing, but in the custom error handler, it does not exist.
Cliff
Cliff
Re: Problems using error object
I looked at different error handlers I have written over the years.
It looks like ProcName(2) and ProcLine(2) will tell you where the error occurred.
It looks like ProcName(2) and ProcLine(2) will tell you where the error occurred.
The eXpress train is coming - and it has more cars.