...
- Add a
throwstatement to your Document Repository CRUD Tool script in the format:
For example:Code Block throw "<httpStatusCode>_<errorMessage>";
Virtualize will put the HTTP status code and the error message into variables namedCode Block var item = db.items.findOne({ id: 1 }) if (item == null) { throw "404_Item does not exist"; }crudToolErrorCodeandcrudToolErrorMessage. - Go to the Document Repository CRUD Tool's parent responder and confirm that Continue searching for a matching responder if data source correlation fails is enabled under Failover Options in the Data Source Correlation tab.
- Add a new responder to the asset and in the Request Correlation tab, add an xpath on the Request Body like:
"404" = "${crudToolErrorCode}"This will capture the request that failed over from the earlier responder. You can configure this responder further, just like any other responder. For example, you could configure the Return Status under the Options tab to use the variablecrudToolErrorCodeas the HTTP response code.See Message Responder Overview for more information about configuring responders.