Hi!
In VO I used BREAK very often to 'jump to the end' if an error was detected from my own program, not only runtime errors.
I tried to use a switch which is set to false if an error occurs:
lok := true
if lOk
xxxx
if <some error>
cMsg = "..."
lOk := false
endif
endif
...
But in this construct I get errors for 'use of uninitialised variables' because the compiler doesn't know that if lOk is true, any initialisation is made.
In X# I use TRY ... CATCH... for Exceptions of .net and runtime, but don't know how to use RAISE and if this makes sense anyway.
Some guidance to the right track?
BR Kurt
How to replace BEGIN SEQUENCE...BREAK...RECOVER for own errors?
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
How to replace BEGIN SEQUENCE...BREAK...RECOVER for own errors?
Hi Kurt
Try:
HTH,
Try:
Code: Select all
TRY
<Statements>
CATCH oEx AS Exception
THROW Exception{oEx:Message}
FINALY
lOk := TRUE/FALSE
END TRY
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa
How to replace BEGIN SEQUENCE...BREAK...RECOVER for own errors?
Hi Jamal,
for me this looks like there is already an exception and it's thrown again...?
But my question is if I can create an exception myself if I detect an error e.g.
if x <> y
throw xxx
and what I have to take care of.
And if this makes sense.
BR Kurt
for me this looks like there is already an exception and it's thrown again...?
But my question is if I can create an exception myself if I detect an error e.g.
if x <> y
throw xxx
and what I have to take care of.
And if this makes sense.
BR Kurt
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
How to replace BEGIN SEQUENCE...BREAK...RECOVER for own errors?
Hi Kurt,
You can also do it like this:
Regards,
Yes you can:kitz wrote: for me this looks like there is already an exception and it's thrown again...?
But my question is if I can create an exception myself if I detect an error e.g.
if x <> y
throw xxx
and what I have to take care of.
Code: Select all
if x <> y
lOk := FALSE
THROW Exception{"Message"}
endif
Code: Select all
TRY
if x <> y
THROW Exception{"Message"}
endif
CATCH oEx AS Exception // THROW will be catch by this
lOk := FALSE
END TRY
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa
How to replace BEGIN SEQUENCE...BREAK...RECOVER for own errors?
Ok, thanks, that's what I have missed.