%Status usage in ObjectScript
Hi developers!
Want to discuss with you the case of %Status.
If you familiar with ObjectScript you know what is it. I'd love to hear the history of the case why it had appeared in ObjectScript but it turned out that almost every system/library classmethods return %Status and there is a whole set of tools to deal with it.
What is does it gives you the responsibility to check the value or %Status of every system method you call.
E.g. if you save the data of the persistent class, you should never call like this:
do obj.%Save()
you need to call:
set sc=obj.%Save()
if $$$ISERR(sc) do // something or quit.
Or if you use try/catch approach in your code you use the following macro:
$$$THROWONERROR(sc,obj.%Save())
Which turns your code into something like:
set sc=$$$OK
Try {
$$$THROWONERROR(sc,##class(x.y).a())
$$$THROWONERROR(sc,##class(x.y).b())
$$$THROWONERROR(sc,##class(x.y).c())
$$$THROWONERROR(sc,##class(x.y).z())
do obj.NormalMethod(parameter)
}
catch e {
// error handling
}
Which makes the code look like a sequence of $$$THROWONERROR calls. Which I don't find very readable.
So, if you introduce a new %Status method, you make ALL the users of this method use either $$$THROWONERROR or $$$ISERR
And my questions are:
What is the value of %Status vs try/catch?
do you use %Status in newly introduced methods of YOUR solutions?
Why?