[Stackoverflow] [Progress OpenEdge ABL] How to catch user interface event trigger error

  • Thread starter Александр Овчинников
  • Start date
Status
Not open for further replies.
А

Александр Овчинников

Guest
How to catch error from ser interface event trigger. For example, in the code below, f6 is updating the data in the ttnom temporary table. In the fill_tt procedure, if the table is empty, PROGRESS.lang.apperror('Temp-table is empty') is thrown. Is it possible to return it from the F6 event to the main block of the program so that it is caught there by the catch block, and not by the catch inside the event.

Code:
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.

Continue reading...
 
Status
Not open for further replies.
Top