Try OpenEdge Now
skip to main content
Object-oriented Programming
Programming with Class-based Objects : Raising and handling error conditions : Raising errors within a property

Raising errors within a property

Error handling for GET and SET accessors works similar to the way it does for methods. In this respect, a GET accessor corresponds to a method (non-VOID) that returns a value and a SET accessor corresponds to a method (VOID) that does not return a value. So, when you read or write a property in a statement, if the property accessor returns ERROR from a RETURN ERROR, an UNDO, THROW, or an unhandled system error, ABL raises the ERROR condition on this statement, which you can handle appropriately in the associated block.
Error handling within property accessors works exactly like it does for raising and handling errors within methods. For example, you can include blocks within property accessors to handle ERROR conditions, using the options of the ON ERROR phrase and you can include CATCH blocks in any UNDO block, including the accessor block.
Note: While you can include most any kind of processing, including UNDO processing, within a property accessor, Progress Software Corporation recommends that you employ the simplest processing possible within property accessors. Avoid any processing that involves long execution times, database processing, or any other processing that might result in unexpected side-effects.
* GET accessors raising ERROR
* SET accessors raising ERROR
* Property error handling example