Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #2998 > unrolled thread

ErrorBlock/Begin Sequence does not work

Started byGrzegorz Ramotowski <ramotny@tlen.pl>
First post2012-02-21 01:32 -0800
Last post2012-02-22 23:43 -0800
Articles 6 — 5 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  ErrorBlock/Begin Sequence does not work Grzegorz Ramotowski <ramotny@tlen.pl> - 2012-02-21 01:32 -0800
    Re: ErrorBlock/Begin Sequence does not work "Marc Verkade [Marti]" <marcatm@rti.nl> - 2012-02-21 11:12 +0100
    Re: ErrorBlock/Begin Sequence does not work "Willie Moore" <williem@wmconsulting.com> - 2012-02-21 07:28 -0600
      Re: ErrorBlock/Begin Sequence does not work Grzegorz Ramotowski <ramotny@tlen.pl> - 2012-02-21 08:06 -0800
        Re: ErrorBlock/Begin Sequence does not work "Stephen Quinn" <stevejqNO@bigpondSPAM.net.au> - 2012-02-23 11:14 +1100
    Re: ErrorBlock/Begin Sequence does not work Mathias <mathias.hakansson@consultec.se> - 2012-02-22 23:43 -0800

#2998 — ErrorBlock/Begin Sequence does not work

FromGrzegorz Ramotowski <ramotny@tlen.pl>
Date2012-02-21 01:32 -0800
SubjectErrorBlock/Begin Sequence does not work
Message-ID<68bbdb31-5b52-413b-9fd2-0f422fa40b81@eb6g2000vbb.googlegroups.com>
Hello Friends,
I have problems opening databases and tried to use BEGIN SEQUENCE but
my code (below) does not work :( - even I wrote an errorhandler it
never gets called and a runtime error ('Workarea not in use, File does
not contain table' (although has and 'Igore' button works fine)
appears. Why?

bLastHandler := ErrorBlock({|oError| MyHandler(oError)})

iLoop:=0
DO WHILE TRUE
  BEGIN SEQUENCE
    dbTmp:=CreateInstance(AsSymbol(sDataBaseName))       // here
happens an error
  RECOVER USING oerr
    IF iLoop<3
      iLoop++
      LOOP
    ENDIF
  END
  EXIT
ENDDO
ErrorBlock(bLastHandler)

and

FUNCTION MyHandler(oError)
//	InfoBox{,"Errorhandler","mój"}:Show(SHOWCENTERED)
  BREAK oError

[toc] | [next] | [standalone]


#2999

From"Marc Verkade [Marti]" <marcatm@rti.nl>
Date2012-02-21 11:12 +0100
Message-ID<4f436e55$0$793$58c7af7e@news.kabelfoon.nl>
In reply to#2998
Hey,
This code does not say enough, i am sorry!

It seems that the server itself is not valid.
Perhaps you create a sample aef that demonstrates the issue.
I am sure 1 or 2 guys will take a look then.

Grtz, Marc

"Grzegorz Ramotowski"  schreef in bericht 
news:68bbdb31-5b52-413b-9fd2-0f422fa40b81@eb6g2000vbb.googlegroups.com...

Hello Friends,
I have problems opening databases and tried to use BEGIN SEQUENCE but
my code (below) does not work :( - even I wrote an errorhandler it
never gets called and a runtime error ('Workarea not in use, File does
not contain table' (although has and 'Igore' button works fine)
appears. Why?

bLastHandler := ErrorBlock({|oError| MyHandler(oError)})

iLoop:=0
DO WHILE TRUE
  BEGIN SEQUENCE
    dbTmp:=CreateInstance(AsSymbol(sDataBaseName))       // here
happens an error
  RECOVER USING oerr
    IF iLoop<3
      iLoop++
      LOOP
    ENDIF
  END
  EXIT
ENDDO
ErrorBlock(bLastHandler)

and

FUNCTION MyHandler(oError)
// InfoBox{,"Errorhandler","mój"}:Show(SHOWCENTERED)
  BREAK oError 

[toc] | [prev] | [next] | [standalone]


#3003

From"Willie Moore" <williem@wmconsulting.com>
Date2012-02-21 07:28 -0600
Message-ID<ji066a$5bu$1@speranza.aioe.org>
In reply to#2998
Gregory,

Where you set a local handler, you need to set it up so it will break and 
call your own code located in the recover using. The only place I have seen 
the errorblock as you have done it is in the mcperrorhandler and you will 
notice with that they did not follow it up with a recover using. Once you 
are in your local recover using, you can call myHandler(uxError) and it will 
execute. I have included a small error handling snippet that should help.

Regards,
Willie

LOCAL uxError AS Usual
LOCAL cb         AS CodeBlock
cb := ErrorBlock( {|e| _Break(e) } )
Begin Sequence
// code goes here
RECOVER USING uxError
    InfoBox{,"Errorhandler","mój"}:Show(SHOWCENTERED)
END SEQUENCE
ErrorBlock( cb )

Regards,
Willie
Vulcan VIP

"Grzegorz Ramotowski"  wrote in message 
news:68bbdb31-5b52-413b-9fd2-0f422fa40b81@eb6g2000vbb.googlegroups.com...

Hello Friends,
I have problems opening databases and tried to use BEGIN SEQUENCE but
my code (below) does not work :( - even I wrote an errorhandler it
never gets called and a runtime error ('Workarea not in use, File does
not contain table' (although has and 'Igore' button works fine)
appears. Why?

bLastHandler := ErrorBlock({|oError| MyHandler(oError)})

iLoop:=0
DO WHILE TRUE
  BEGIN SEQUENCE
    dbTmp:=CreateInstance(AsSymbol(sDataBaseName))       // here
happens an error
  RECOVER USING oerr
    IF iLoop<3
      iLoop++
      LOOP
    ENDIF
  END
  EXIT
ENDDO
ErrorBlock(bLastHandler)

and

FUNCTION MyHandler(oError)
// InfoBox{,"Errorhandler","mój"}:Show(SHOWCENTERED)
  BREAK oError 

[toc] | [prev] | [next] | [standalone]


#3006

FromGrzegorz Ramotowski <ramotny@tlen.pl>
Date2012-02-21 08:06 -0800
Message-ID<288a7701-a325-4c12-b7fe-8048b7332281@e27g2000vbu.googlegroups.com>
In reply to#3003
@ marc
Server IS valid (I mean the file exists and is correct) because it
does not happen always but only sometimes – however always with the
same file (so far). I don't think full AEF will help You – there is a
lot of code not related to problem but I made a MEF with (IMHO) most
important code: main function with errorhandler, database Init
modification – mef can be downloaded from here:
http://www.nowimex.futuro.info.pl/vo/VOGroup.MEF - If You need more
just mention.

@willie
I don't see difference between my code and Your code – in my code
BREAK is included in separate MyHandler function (I showed it) and
according to VO helpfile it's enough it remains in the same entity as
Begin Sequence (and it is so).

In fact there are two problems in one:
1)- file on server is valid, working database but sometimes yelds
'Workarea not in use / does not contain table' error at
CreateInstance()
2)- my errorhandler (loop-maker) is not called/executed when this
runtime error happens

I just want to make a loop that tries to open n-times a database
object – I found that even if at first attempt CreateInstance fails –
at second (for example after Ignore button in error popup) – works. It
NEVER happens when I run program from within GUI but happens
(sometimes not always!) when run from EXE and only over network.
Locally never (so far).

I got stuck... :(

[toc] | [prev] | [next] | [standalone]


#3022

From"Stephen Quinn" <stevejqNO@bigpondSPAM.net.au>
Date2012-02-23 11:14 +1100
Message-ID<5Bf1r.3323$v14.861@viwinnwfe02.internal.bigpond.com>
In reply to#3006
Grzegorz

> I don't see difference between my code and Your code – in my code
> BREAK is included in separate MyHandler function (I showed it) and
> according to VO helpfile it's enough it remains in the same entity as
> Begin Sequence (and it is so).
Begs the question - why are you using it then?
You may just as well put BREAK in there and forgo the use of an error 
handler that does bugger all.

> NEVER happens when I run program from within GUI but happens
> (sometimes not always!) when run from EXE and only over network.

Network slowness could be the problem then.
May be the system has disconnected the SHARED volume and needs time to 
reconnect.

> 2)- my errorhandler (loop-maker) is not called/executed when this runtime 
> error happens
Probably because the error occurs AFTER the routine has ended and the system 
error handler is back in place.

////////////////////////////
You create an instance of the Server
You don't test to see if the Server is 'used'
You EXIT the loop
You return from the function
    ERROR here in the calling routine

Seeing as you don't show the code around  the CALLING routine
    - Are you testing to see if the Server is VALID before using it?
Eg
    oServer := Whatever()
    IF oServer:Used
        // rest of code using valid server
    ELSE
        // ErrorBox
    ENDIF

CYA
Steve

[toc] | [prev] | [next] | [standalone]


#3028

FromMathias <mathias.hakansson@consultec.se>
Date2012-02-22 23:43 -0800
Message-ID<25158772.6553.1329982987753.JavaMail.geo-discussion-forums@vbai14>
In reply to#2998
Hi Grzegorz,

how do you know that your errorhandler does not get called. In my eyes it looks like your errorhandler only calls the original errorhandler. Try to use an errorhandler like this:

function MyErrorHandler(oError, lLocalHandler)
	if lLocalHandler
		break oError
	endif

	return nil

 and set it up like this:

bLastHandler := ErrorBlock({|oErr| MyErrorHandler(oErr,true) })

This works for me. When I open the database I specify the path. Try if this helps.

db := CreateInstance(symclass,sFile,DBSHARED,DBREADWRITE)

My recover statement looks like this:

recover using oLocal
	ErrorBlock(bLastHandler)
				
	do case
	case oLocal:oscode == 2	// File missing. Create file
		if MyCreateDB(oLocal)
			db := CreateInstance(symclass,file,DBEXCLUSIVE,DBREADWRITE)
			if !CreateIndex(db)
				lerror := false
				Eval(bLastHandler,oLocal)
				db := CreateInstance(symclass,file,DBSHARED,DBREADWRITE)
			else
				db:Close()
				db := CreateInstance(symclass,file,DBSHARED,DBREADWRITE)
				lerror := false
			endif
		else	// Create standard error
			lerror := false
			Eval(bLastHandler,oLocal)	// Generate an ordinary error.
		endif
	case oLocal:oscode == 32	// File sharing error
		InfoBox{,"Database check",;
			"Tried to adjust database " + file + ", but failed due to a file sharing error!" + CrLf +;
			ListStack()}:Show()
		lerror := false
		db := CreateInstance(symclass,file,DBSHARED,DBREADWRITE)
	case oLocal:oscode == 5	// Access denied
		InfoBox{,file,"Could not open " + file + ". File is write protected or privilegies are insufficient"}:Show()
		lerror := false
	case InList(oLocal:subcode,2035,2006)	// fpt-file missing, or write protected. Corrupted
		InfoBox{,file,oLocal:operation}:Show()
		lerror := false
	otherwise
		lerror := false
		if !Empty(oLocal:ArgNum) .and. (oLocal:ArgNum <= ALen(oLocal:Args))
			sArg := AsString(oLocal:Args[oLocal:ArgNum])
			wArgType := UsualType(oLocal:Args[oLocal:ArgNum])
		endif

		InfoBox{,"DBCheck error",file + CrLf + CrLf + sarg + Str(wargtype) + Symbol2String(oLocal:funcsym) +;
												  oLocal:operation + Str(oLocal:subcode) + oLocal:Subcodetext +;
			  Str(oLocal:oscode) + CrLf + ListStack()}:Show()
	endcase
end sequence

/Mathias

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web