T
temays
Guest
I'm seeing a little weirdness using catch in a repeat block versus a for each (see the code below.) If in an error is encountered in a repeat/get-next table navigation block (the example uses a query but repeat/find next reacts the same way), the catch fires but immediately exits the repeat block, regardless of any undo, retry options. However when navigating the table via a for each block and forcing the same error, I see the catch statement firing, and then staying within the iterating block. Is this expected behavior? I would hope to catch and process the error, programmatically determine whether or not to continue table navigation, regardless of how i was moving through the data. /*Uses sports - for sports2000 change cust-num to custnum*/ &SCOPED-DEFINE Test_type REPEAT /* Set to REPEAT or anything else to use for each*/ &IF "{&Test_type}" EQ "REPEAT" &THEN define variable hQuery as handle no-undo. define variable cnt as int no-undo. create query hQuery. hQuery:set-buffers(buffer sports.customer:handle). hQuery:query-prepare("FOR EACH sports.Customer NO-LOCK"). hQuery:query-open(). rep-blk: repeat on error undo, retry: hQuery:get-next(). cnt = cnt + 1. message "Repeat/get-next Cnt = " cnt " cust-num = " cust-num view-as alert-box. IF cnt = 2 then assign sports.customer.cust-num = 1. /*Force an error(NO-LOCK update)*/ CATCH myAppError As Progress.Lang.AppError: MESSAGE "in catch block - Lang.AppError " VIEW-AS ALERT-BOX. undo, next rep-blk. END CATCH. CATCH mySysError AS Progress.Lang.SysError: MESSAGE "in catch block - Lang.SysError " mySysError:GetMessage(1) VIEW-AS ALERT-BOX. undo, next rep-blk. END CATCH. CATCH myProError AS Progress.Lang.ProError: MESSAGE "in catch block - Lang.ProError" mySysError:GetMessage(1) VIEW-AS ALERT-BOX. undo, next rep-blk. END CATCH. CATCH myError AS Progress.Lang.Error: MESSAGE "In catch block - Lang.Error " myError:GetMessage(1) VIEW-AS ALERT-BOX. undo, next rep-blk. END CATCH. END. message "Outside of repeat" view-as alert-box. &ELSE define variable cnt as int no-undo. rep-blk: FOR EACH sports.Customer NO-LOCK: cnt = cnt + 1. message "For each - Cnt = " cnt " cust-num = " cust-num view-as alert-box. IF cnt = 2 then assign sports.customer.cust-num = 1. /*Force an error(NO-LOCK update)*/ CATCH myAppError As Progress.Lang.AppError: MESSAGE "in catch block - Lang.AppError " VIEW-AS ALERT-BOX. undo, next rep-blk. END CATCH. CATCH mySysError AS Progress.Lang.SysError: MESSAGE "in catch block - Lang.SysError " mySysError:GetMessage(1) VIEW-AS ALERT-BOX. undo, next rep-blk. END CATCH. CATCH myProError AS Progress.Lang.ProError: MESSAGE "in catch block - Lang.ProError" mySysError:GetMessage(1) VIEW-AS ALERT-BOX. undo, next rep-blk. END CATCH. CATCH myError AS Progress.Lang.Error: MESSAGE "In catch block - Lang.Error " myError:GetMessage(1) VIEW-AS ALERT-BOX. undo, next rep-blk. END CATCH. END. message "Outside of for each " view-as alert-box. &ENDIF
Continue reading...
Continue reading...