Raise errors in a SET accessor
- Last Updated: January 16, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
A SET accessor runs when you set the
value of the property, for example, on the left side of an Assignment
(=) statement or when you pass the property as an OUTPUT parameter. When
a SET accessor raises ERROR, it can
produce a different result from a property or method raising ERROR on
the right side of the assignment.
Thus, after executing the following assignment statement, the iVal variable
either changes to the value returned by expression or ERROR is
raised on the statement from some problem in expression, in which case iVal remains
unchanged at 5:
|
However, in the following assignment statement, if the SET accessor
for the iPropVal property does a RETURN
ERROR or an UNDO, THROW, the value of iPropVal will
retain its latest value prior to raising ERROR,
which can well be the value returned by expression:
|
The actual value retained by iPropVal if its SET accessor
raises ERROR depends on how you code the SET accessor.
ERROR,
the SET accessor of the left-side property never
runs.When a property appears on the left side of an assignment and
the SET accessor raises ERROR,
the property can retain its latest value prior to raising ERROR depending
on NO-UNDO settings, the property default memory,
and any other data that the SET accessor changes. This
is no different than any method that raises ERROR, except
that the method (SET accessor) is executing on
the left side of the assignment, independent of any right-side result.
In a similar fashion, when you pass a property as a routine OUTPUT parameter,
if the property SET accessor raises ERROR,
and depending on NO-UNDO settings, the SET accessor
can leave all data that it affects at their latest values prior
to raising ERROR.