如何捕获用户界面事件触发错误

How to catch user interface event trigger error

如何从 ser 接口事件触发器中捕获错误。 例如,在下面的代码中,f6 正在更新 ttnom 临时 table 中的数据。在 fill_tt 过程中,如果 table 为空,则抛出 PROGRESS.lang.apperror('Temp-table is empty')。 是否可以 return 它从 F6 事件到程序的主块,以便它被 catch 块捕获,而不是被事件内部的 catch 捕获。

BLOCK-LEVEL ON ERROR UNDO, THROW.

DEFINE VARIABLE inomtr AS i NO-UNDO.
DEFINE VARIABLE lexit AS L NO-UNDO.

DEFINE TEMP-TABLE ttnom NO-UNDO 
  FIELD uid AS int64
INDEX idx1 IS unique uid.  

DEFINE FRAME fupd
SKIP(1)
inomtr FORMAT '>>>>>>>>>>>9' NO-LABEL
SKIP(1)
WITH VIEW-AS DIALOG-BOX SIDE-LABELS.

 ON GO OF FRAME fupd
 DO:
   _t1:
   DO ON ERROR UNDO, RETURN NO-APPLY: 
     ASSIGN inomtr.
     IF CAN-FIND (FIRST ttnom NO-LOCK WHERE ttnom.uid = inomtr) THEN 
         LEAVE _t1.
     MESSAGE 'inomtr not found' VIEW-AS ALERT-BOX.
     RETURN NO-APPLY.    
   END.   
 END.
 
ON F3 OF inomtr IN FRAME fupd
DO:
  RUN choose_nom(OUTPUT inomtr).
END.

ON F6 of FRAME fupd ANYWHERE 
DO:
  DO ON ERROR UNDO, THROW  :
     RUN fill_tt.
     CATCH ERROR AS PROGRESS.lang.error:
        message error:GetMessage(1) + return-value VIEW-AS ALERT-BOX.
        lexit = YES.
        STOP.
     END CATCH.
  END.
  RETURN NO-APPLY.
END.

 
_tr:
DO ON ERROR UNDO, THROW
   ON STOP UNDO, LEAVE
   ON ENDKEY UNDO, LEAVE:

  RUN fill_tt.    
  DO WHILE TRUE ON ERROR UNDO, throw
                ON STOP UNDO , RETRY 
                ON ENDKEY UNDO , RETRY :
     IF RETRY OR lexit = yes THEN 
        DO:
          IF lexit = NO THEN 
             MESSAGE 'Exit?' VIEW-AS ALERT-BOX BUTTONS YES-NO UPDATE lexit.
          IF lexit = YES THEN 
             LEAVE _tr.    
        END.          
     DISPLAY  WITH FRAME fupd.
     ENABLE inomtr WITH FRAME fupd.

     WAIT-FOR GO OF FRAME fupd.

     RUN do_nomtr(inomtr).         
  END. 
  CATCH ERROR AS PROGRESS.lang.error:
     message ERROR:GetMessage(1) + RETURN-VALUE VIEW-AS ALERT-BOX.
  END CATCH.  
END.

PROCEDURE do_nomtr:
   DEFINE INPUT PARAM inomtr AS i NO-UNDO.

   MESSAGE inomtr VIEW-AS ALERT-BOX.
END PROCEDURE.

PROCEDURE fill_tt:
  DO ON ERROR UNDO, THROW:
     DISPLAY 'Loading temp-table' WITH FRAME ftt VIEW-AS DIALOG-BOX.
     EMPTY TEMP-TABLE ttnom.
     FOR EACH link NO-LOCK WHERE link.type = 3 AND link.class-code = '1B' AND 
                                 link.file-name = 'r-goods' AND link.arch = no ON ERROR UNDO, THROW:
                IF CAN-FIND(FIRST ttnom WHERE ttnom.uid = link.link-num) THEN 
                   NEXT.
                CREATE ttnom.
                ASSIGN ttnom.uid = link.link-num.                
     END.                                             

     HIDE  FRAME ftt NO-PAUSE.
     IF NOT TEMP-TABLE ttnom:HAS-RECORDS THEN 
        UNDO, THROW NEW PROGRESS.lang.apperror('Temp-table is empty').
  END.
END PROCEDURE.

main-block 无法从触发器捕获错误。你应该在每个 trigger-block.

中都有一个 catch 块

如果您想超越 wait-for(在 main-block),您需要应用 GO 事件。