提升4GL中的几个运行时错误

时间:2014-03-27 12:47:51

标签: error-handling runtime-error progress-4gl openedge

我想测试一些正在进行的AppServer错误处理。但是,为了测试它,我想用num-messages> = 2运行时错误。你怎么能产生这样的多个错误?


以下是我正在尝试做的一些示例

IF ERROR-STATUS:ERROR THEN      
   LogToAppserver().

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

LogToAppserver看起来像

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.

1 个答案:

答案 0 :(得分:3)

试试此代码

DEF VAR h AS HANDLE NO-UNDO.      

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

它应该提供2条消息。