/* First technique for returning a system error from a user-defined function. */
DEFINE VARIABLE FuncReturn AS LOGICAL NO-UNDO. FUNCTION ReturnSysError RETURNS LOGICAL: FIND FIRST Customer WHERE CustNum = 1000. CATCH mySysError AS Progress.Lang.SysError: UNDO, THROW mySysError. END CATCH. END FUNCTION. ASSIGN FuncReturn = ReturnSysError(). CATCH mySysError AS Progress.Lang.SysError: DISPLAY "Error message returned from function: " mySysError:GetMessage(1) FORMAT "X(60)" SKIP. END CATCH. |
/* Second technique for returning a system error from a user-defined function.
*/ DEFINE VARIABLE FuncReturn AS LOGICAL NO-UNDO. FUNCTION ReturnSysError RETURNS LOGICAL: FIND FIRST Customer WHERE CustNum = 1000. CATCH mySysError AS Progress.Lang.SysError: UNDO, THROW mySysError. END CATCH. END FUNCTION. ASSIGN FuncReturn = ReturnSysError() NO-ERROR. IF ERROR-STATUS:ERROR THEN DISPLAY "Error message returned from function: " ERROR-STATUS:Get-Message(1) FORMAT "X(60)". |
/* Third technique for returning a system error from a user-defined function.
*/ ROUTINE-LEVEL ON ERROR UNDO, THROW. DEFINE VARIABLE FuncReturn AS LOGICAL NO-UNDO. FUNCTION ReturnSysError RETURNS LOGICAL: FIND FIRST Customer WHERE CustNum = 1000. END FUNCTION. ASSIGN FuncReturn = ReturnSysError(). CATCH mySysError AS Progress.Lang.SysError: DISPLAY "Error message returned from function: " mySysError:GetMessage(1) FORMAT "X(60)" SKIP. END CATCH. |