RobotStudio event

RAISE and ERROR from TRAP ROUTINE

Options
I am trying to raise an error from a TRAP routine, I achieve this when in the upper routine the error is handled in this way:
ERROR(MY_ERROR)
.....ACTIONS...

However, when I have more than one error handled and I have to handle it this way:

ERROR
IF ERRNO=MY_ERROR THEN

I get that the error is not controlled. I don't know what to do.
The trap routine is handled like this:

 TRAP t_trap_Empty
    
   
    RAISE err_empty_stop;
    
    ERROR
     RAISE;
         
  ENDTRAP

Thank you very much!!!


Answers

  • lemster68
    lemster68 ✭✭✭
    Options
    The error which has occurred might not be what you expect it to be.  I recommend changing from IF THEN to a TEST CASE.  Include a default and stop the program execution.  Then you can view the value stored in the system ERRNO and compare it to find the actual error at that time.
    Lee Justice
  • lemster68 said:
    The error which has occurred might not be what you expect it to be.  I recommend changing from IF THEN to a TEST CASE.  Include a default and stop the program execution.  Then you can view the value stored in the system ERRNO and compare it to find the actual error at that time.
      Okey, would you give me an example? I am new here. THX!!!
  • lemster68
    lemster68 ✭✭✭
    Options
    Here is one:

    ERROR
        TEST ERRNO
        CASE erNumFault:
          TPWrite astNumFault{1};
          TPWrite "The program number received was: "\Num:=nProgramNumber;
          TPReadFK nDummy,"Press EXIT to exit:","","","","Exit","";
          EXIT;
        DEFAULT:
          TPErase;
          TPReadFK nDummy,"Handshaking was unsuccessful.           Press EXIT to exit:","","","","Exit","";
          EXIT;
        ENDTEST
    I often put a placeholder for an instruction in the default <SMT>.  This will cause an execution error, which WILL bring attention to the pendant.  At this point one would view the ERRNUM datatype, find the value in ERRNO, and then find the corresponding predefined errors to find that which matches.  Then you will know exactly what the error was.  I highly recommend doing it this way because there are times when an error that you NEVER anticipated has occurred.

    Lee Justice