API Help
EPLAN API / User Guide / API Miscellaneous / Throwing and catching exceptions
Throwing and catching exceptions

Error handling in EPLAN is done preferentially by using exceptions. The API framework provides the base class BaseException , which gives you access to the error handling of EPLAN. 

If an Exception object of this type is thrown, the EPLAN framework catches the exception and writes the data into the systems error management or shows the error message in the EPLAN error dialog. 

Eplan.EplApi.Base.BaseException exc2= new Eplan.EplApi.Base.BaseException(
                                                "Error from CSharpAction thrown as exception",
                                                Eplan.EplApi.Base.MessageLevel.Error);

throw exc2;

 

Of course you can also catch exceptions in your API application and evaluate them, to e.g. display your own error message. 

           // Test wrong settings name (throws BaseException, which is handled here)
            try
            {
                String strGuiLanguage= Settings.GetStringSetting("USER.SYSEM.GUI.LANGUAGE", 0);
                new Decider().Decide(EnumDecisionType.eOkDecision, "The current GUI language is: "+ strGuiLanguage, "", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK);
            }
            catch (BaseException exc)
            {
                String strMessage= exc.Message;
                new Decider().Decide(EnumDecisionType.eOkDecision, "Exception: " + strMessage, "", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK);
            }