CATCH error-variable AS CLASS error-class:
. . . END CATCH . |
DEFINE VARIABLE oneError AS CLASS Progress.Lang.SysError.
/* This definition not necessary. */ DO ON ERROR UNDO, LEAVE: FIND FIRST Customer WHERE CustNum = 5000. CATCH oneError AS Progress.Lang.SysError: MESSAGE oneError:GetMessage(1) VIEW-AS ALERT-BOX BUTTONS OK. END CATCH. CATCH twoError AS Progress.Lang.ProError: MESSAGE twoError:GetMessage(1) VIEW-AS ALERT-BOX BUTTONS OK. END CATCH. END. /* FIRST DO */ DO ON ERROR UNDO, LEAVE: FIND FIRST Customer WHERE CustNum = 6000. /* You can reuse an error-variable from a different associated block */ CATCH oneError AS Progress.Lang.SysError: MESSAGE oneError:GetMessage(1) VIEW-AS ALERT-BOX BUTTONS OK. END CATCH. /* NOT LEGAL: Each CATCH block in an associated block must have a unique error-variable. */ CATCH oneError AS Progress.Lang.ProError: MESSAGE oneError:GetMessage(1) VIEW-AS ALERT-BOX BUTTONS OK. END CATCH. END. /* SECOND DO */ |
DO TRANSACTION
. . . CATCH . . . : . . . END CATCH. END. |
DEFINE VARIABLE iCust AS INTEGER.
ASSIGN iCust = 5000. FIND Customer WHERE CustNum = iCust. /* Will fail */ /* Won't execute because FIND fails */ MESSAGE "Customer found" VIEW-AS ALERT-BOX BUTTONS OK. /* The associated block for this CATCH block is the main block of the .p */ CATCH eSysError AS Progress.Lang.SysError: MESSAGE "From CATCH block..." SKIP eSysError:GetMessage(1) VIEW-AS ALERT-BOX BUTTONS OK. END CATCH. |
FOR EACH Customer:
/* Code body of the associated block */ /* This CATCH specifies the most specialized user-defined error class. It will catch only myAppError error objects or objects derived from myAppError. */ CATCH eMyAppError AS Acme.Error.myAppError: /*Handler code for Acme.Error.myAppError condition. */ END CATCH. /* This CATCH will handle Progress.Lang.AppError or any user-defined application error type, except for eMyAppError which is handled by the preceding CATCH block. */ CATCH eAppError AS Progress.Lang.AppError: /* Handler code for AppError condition. */ END CATCH. /* This CATCH will handle any error raised by an ABL statement. Since it inherits from the same object as AppError in the class hierarchy, this CATCH could come before or after the CATCH for AppError */ CATCH eSysError AS Progress.Lang.SysError: /* Handler code for SysError condition. */ END CATCH. /* This will catch any possible error raised in ABL. */ CATCH eError AS Progress.Lang.Error: /* Handler code for any error condition. */ END CATCH. END. /* Associated Block */ |
FOR EACH Customer:
/* Code body of the associated block */ /* This will catch all application errors */ CATCH eAppError AS Progress.Lang.AppError: /* Handler code for AppError condition */ END CATCH. /* Never get here, because myAppError is a subtype of Progress.Lang.AppError */ CATCH eMyAppError AS Acme.Error.myAppError: /* Handler code for myAppError condition */ END CATCH. END. /* Associated Block */ |