Problems using error object

This forum is for eXpress++ general support.
Message
Author
Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Problems using error object

#1 Post by Cliff Wiernik »

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

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Problems using error object

#2 Post by Cliff Wiernik »

My error. the instance variable is args, not arguments.

Thus I generated an error inside my recover using statements.

Cliff

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Problems using error object

#3 Post by rdonnay »

Thus I generated an error inside my recover using statements.
That was my first guess.
The eXpress train is coming - and it has more cars.

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Problems using error object

#4 Post by Cliff Wiernik »

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.

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Problems using error object

#5 Post by rdonnay »

How do I get the line causing the error,
You have to walk through the stack in a for..next loop:

FOR i := 1 to 10
wtf Procname(i), ProcLine(i)
NEXT
The eXpress train is coming - and it has more cars.

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Problems using error object

#6 Post by Cliff Wiernik »

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.

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Problems using error object

#7 Post by Cliff Wiernik »

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.
errorline.jpg
errorline.jpg (31.78 KiB) Viewed 15261 times

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Problems using error object

#8 Post by rdonnay »

Look at Alaska's errorsys.prg. It may help you.
The eXpress train is coming - and it has more cars.

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Problems using error object

#9 Post by Cliff Wiernik »

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

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Problems using error object

#10 Post by rdonnay »

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.
The eXpress train is coming - and it has more cars.

Post Reply