Error Path: Managing Errors and Response Mapping | Error Selector: Handling Errors and Custom Responses | Circuit | Online Help

Error Selector and Error Path

Error Selector and Error Path are used to manage errors in a system. While Result Selector and Result Path control the output of a state upon successful execution, Error Selector and Error Path come into play when the are exceptional circumstances, enabling a fallback to the next state in case of an error during execution. This feature is not available for Flow Controls but is specifically designed for Functional states and Bridge Controls.

Error Selector

Error Selector is used to define how the system should respond when an error occurs during state execution. It lets you configure specific actions or data to be used in response to an error. You define key-value pairs, similar to Result Selector, where each key represents an action or error data. These values can be either static or derived from the error details.

For example, in an employee onboarding system, you might configure Error Selector to extract error codes and messages dynamically from error details during execution.
Here's how you can configure an Error Selector in Code view. To define static error values:

"error_selector": {
"error_code": "EXC_TME_EXC",
"error_message": "Execution Time Exceeded"
}

To dynamically retrieve error details from the execution during error scenarios:
"error_selector": {
   "error_code": "$.error_code",
"error_message": "$.error_description"
}

In this example, when an error occurs, the system will extract the "error_code" and "error_description" from the error details and make them available for further processing or response.

Error Path

Error Path specifies the location where the error details should be directed for further analysis or handling. If the Error Path isn't specified, the processed input from the previous state is automatically sent to a designated fallback state when an error occurs.
In your employee onboarding system, you may need to direct error details to a designated path, like $.error. Here's how you can set up the Error Path in the Code view:

{
 "onboard_employee": {
"type": "function",
"next": "End",
"start": true,
"function_id": "function_emp_onboard_1",
"on_error": [
{
"error_type": "timeout_error",
"fallback": {
"next": "End",
"error_selector": {
"error_code": "EXC_TME_EXC",
  "error_description": "Execution Time Limit Exceeded"
},
"error_path": "$.error"
}
}
   ]
 }
}


In this case, the error details are sent to the $.error path for further evaluation and appropriate action.
The example JSON below illustrates sample error details generated by the system during an error occurrence, providing information about the error's nature and context for further actions. 

{
      "status": "error",
      "message": "Employee onboarding failed",
      "error_code": "EXC_TME_EXC",
      "error_description": "Execution Time Exceeded"
}




    • Related Articles

    • Result Selector and Result Path

      Result Path and Result Selector are employed to extract dynamic data from the state's result when the execution is successful. Result Selector Result Selector lets you retrieve and process the runtime data, enabling flexible and dynamic data ...
    • Error Handling

      In Qntrl Circuit, you can configure error handling while building a circuit. State definition errors are detected even before saving the circuit. When you save the circuit, a compilation check runs and lists out errors related to its state ...
    • Output Path

      Output Path enables you to select a portion of the state's output and transfer it to the next state for processing, eliminating any unecessary objects from the JSON output. If the Output Path isn't specified, the entire JSON node (determined by the ...
    • Input Path

      Input Path enables you to filter and control the actual input passed to the state. By defining an Input Path (either in Builder View or Code View), using JSONPath notation, you can select a portion of the JSON input and use it for processing within ...
    • JSON Path

      Path serves to locate specific parts or components within a JSON object. These paths start with the '$' symbol and follow JSONPath syntax. It is used to access particular elements or values within JSON objects passed in the Input Path, Output Path, ...

    You are currently viewing the help articles of Qntrl 3.0. If you are still using our older version and require guidance with it, Click here.