Share this page

# Continue on Error

In cases where no value is found by a Query, you can use the NotFound parameter to control the consequent behavior of the script. The value of NotFound can be one of:

Error: the default value, causing an error and script execution to cease

Continue: execution continues, and no error is issued. A warning message is sent to the Execution Log window.

## Example

The following example attempts to insert an XML fragment into an XML string, but the query fails because it cannot find the tag /acme_org/department/employee. The script would terminate at this point if the default NotFound behavior of Error was in effect. However, the lr_xml_insert call specifies NotFound=Continue, and script execution continues to the next statement, lr_output_message.

    #include "as_web.h"

    char *xml_input =
    "<acme_org>"
         "<employee>"
              " <name>John Smith</name>"
              "<cubicle>227</cubicle>"
         "</employee>"
    "</acme_org>";

    Action() {

         lr_save_string(xml_input, "XML_Input_Param");

         lr_xml_insert("XML={XML_Input_Param}", "ResultParam=Result",
              "XmlFragment=<extension>2145</extension>",
              "Query=/acme_org/department/employee",
              "Position=child",
              "NotFound=Continue", LAST );

         lr_output_message("Reached here");

         return 0;
    }

Example: Output:
Action.c(15): Warning: "lr_xml_insert" found no matches
Action.c(21): Reached here

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: