Question

I want to test some AppServer error handling in progress. However, in order to test it I would like a run-time error with num-messages >= 2. How can you generate such multiple errors?


Here are some samples of what I am trying to do

IF ERROR-STATUS:ERROR THEN      
   LogToAppserver().

and

CATCH e AS Progress.Lang.Error :
    LogToAppserver(e).
END CATCH.  

where LogToAppserver looks like

METHOD PRIVATE VOID LogToAppserver(  ):

    DEFINE VARIABLE locNumErrors AS INTEGER NO-UNDO.

    locNumErrors = ERROR-STATUS:NUM-MESSAGES.

    DO WHILE locNumErrors > 0:
        MESSAGE ERROR-STATUS:GET-MESSAGE (locNumErrors).
        locNumErrors = locNumErrors  - 1.
    END.

    RETURN.

END METHOD.

METHOD PRIVATE VOID LogToAppserver( INPUT iError AS Progress.Lang.Error ):

    DEFINE VARIABLE locNumErrors AS INTEGER NO-UNDO.

    locNumErrors = iError:NumMessages.

    DO WHILE  locNumErrors >0:

        MESSAGE iError:GetMessage(locNumErrors ).

        locNumErrors  = locNumErrors - 1.

    END. 

    RETURN.

END METHOD.
Was it helpful?

Solution

Try this code

DEF VAR h AS HANDLE NO-UNDO.      

CREATE SERVER h.                  
h:CONNECT("") NO-ERROR.           
DISPLAY ERROR-STATUS:num-messages.

It should give 2 messages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top