Error handling |
Top Previous Next |
Scripts > Class elements and c++ instructions > Parser class methods > Plugin methods > Error handling
void UseExcept(bool xbUseExcept)
By this command you can determine, whether the parsing in case of a bug shall be interrupted by an exception (xbUseExcept == true) or, whether the error message is stored intermediately in a container of the plugin class and the abort is done by the fact, that for the next token the symbol number null is given back.
bool GetUseExcept() const
returns, whether the parsing in case of a bug will be interrupted by an exception or, whether the abort is managed by returning the symbol number null for the next token.
bool HasError() const
HasError returns true, if a parsing bug has occurred, which hasn't triggered an exception, because UseExcept was set to false. If HasError is true, you have the chance to execute some action immediately after the error occurred, before the parsing aborts. After the execution of a production that was invoked directly from the semantic code every error, which might have happened hereby is deleted, so that HasError returns false.
void GenError(const str& xs)
By the call of GenError an error is created, which leads to an abort of the parsing. A string that contains the error message is passed to the function. This report is displayed in the log window after the abort of parsing. If UseExcept is not set the parsing will be finished regularly, otherwise the abort is done by an exception similar to the throw command. The exception, which is created by GenError however contains additional information about the location of the error. . void AddMessage(const str& xs) void AddWarning(const str& xs) void AddError(const str& xs)
The plugin class now has per default a container (vector), by which messages, warnings and errors can be assembled For this there are the three methods: AddMessage, AddWarning and AddError with a text string as parameter. These strings are shown in the log window after the parsing has finished or they appear in the result window of the transformation manager, if the project was executed there.
In the exported c++ code you get two iterators by the methods MsgBegin and MsgEnd by which you can access the messages, which are derived from CTT_Message. By HasMsg can be proved whether there is a message in the container and by the method GetMsgType of CTT_Message you get one of the enumerated types: eMessage, eExit, eWarning, eError, eParseError or eSemError.
|
This page belongs to the TextTransformer Documentation |
Home Content German |