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

    • 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 ...
    • 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 ...
    • Failure

      The Failure state is also an end state that signifies the failure of the previous task executed in the Circuit and stops its execution, marking it as a failure. It is used to represent a failed execution for the user's reference. Example Use Case: In ...
    • 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, ...
    • Execution Logs

      A record of all tested executions is maintained in Circuit, allowing you to access and re-run specific executions anytime. Follow these steps to access the execution history of a circuit: Access Execution History Go to the left pane and click on the ...

    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.