Error handling in EPLAN is preferably done using exceptions. The API framework provides the BaseException base class that provides 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 to the system error management or shows the error message in the EPLAN error dialog.
Of course, you can also catch exceptions in your API application and evaluate them, e.g. to display your own error message.