I don't think this is the best coding style for error handling, but am curious. Why doesn't the return value get populated from 'doIt'? Does the RETURN simply become unreachable code?
DEFINE VARIABLE cError AS CHARACTER NO-UNDO. RUN doIt. MESSAGE RETURN-VALUE VIEW-AS ALERT-BOX. PROCEDURE doIt: DEFINE VARIABLE cValue AS CHARACTER NO-UNDO. FIND customer NO-LOCK WHERE customer.Name = "buttface". RETURN cValue. CATCH e AS PROGRESS.Lang.SysError: cValue = e:getMessage(1). END CATCH. END PROCEDURE.
I don't think this is the best coding style for error handling, but am curious. Why doesn't the return value get populated from 'doIt'? Does the RETURN simply become unreachable code?
DEFINE VARIABLE cError AS CHARACTER NO-UNDO.
RUN doIt.
MESSAGE RETURN-VALUE VIEW-AS ALERT-BOX.
PROCEDURE doIt:
DEFINE VARIABLE cValue AS CHARACTER NO-UNDO.
FIND customer NO-LOCK
WHERE customer.Name = "buttface".
RETURN cValue.
CATCH e AS PROGRESS.Lang.SysError:
cValue = e:getMessage(1).
END CATCH.
END PROCEDURE.
Flag this post as spam/abuse.
Slightly less tersely ... when the error occurs, it jumps to the catch, right over the return.
Slightly less tersely ... when the error occurs, it jumps to the catch, right over the return.
Flag this post as spam/abuse.
Slightly less tersely ... when the error occurs, it jumps to the catch, right over the return.
Flag this post as spam/abuse.
Flag this post as spam/abuse.
I do recommend the little box at the right end of the rich formatting screen for posting code.
I do recommend the little box at the right end of the rich formatting screen for posting code.
Flag this post as spam/abuse.
that's because you used "buttface" ;)
doing stuff with MyLittlePony would never raise an error ...
Jeff, if you click Use Rich Formatting at the bottom right you get a box with two lines of icons on the top strip. The rightmost icon on the lower row looks like a square with a pencil in it. That's the one. It gives you a box you can past the code into and pick the language.
that's because you used "buttface" ;)
doing stuff with MyLittlePony would never raise an error ...
Flag this post as spam/abuse.
Jeff, if you click Use Rich Formatting at the bottom right you get a box with two lines of icons on the top strip. The rightmost icon on the lower row looks like a square with a pencil in it. That's the one. It gives you a box you can past the code into and pick the language.
Flag this post as spam/abuse.
that's because you used "buttface" ;)
doing stuff with MyLittlePony would never raise an error ...
Flag this post as spam/abuse.
So, posting code is a good reason not to reply by e-mail ... :)
You guys are so entertaining!
it was taken away from me ...
If you put the return cValue in the finally block after the catch, wouldn't you get what you want or were you trying to avoid the finally block? I think there was some issue though where the finally block was not handling returns like this so maybe this only works with 11.x and up.
DEFINE VARIABLE cValue AS CHARACTER NO-UNDO init 'no-error'. FIND customer NO-LOCK WHERE customer.Name = "bumface". CATCH e AS PROGRESS.Lang.SysError: cValue = e:getMessage(1). END CATCH. finally: return cValue. end.
I'm thinking of this:
knowledgebase.progress.com/.../P164717
Different type of issue but good to note.
Also note that the behaviour of flow-of-control statements in a FINALLY block changed in 11.4, to be more logical. More info at documentation.progress.com/.../OpenEdge.40.html