# Error Handling

In Kumologica, robust error handling is an integral part of creating reliable and resilient flows. The Catch node plays a pivotal role in managing errors within a flow. By strategically placing Catch nodes, you can gracefully handle exceptions, ensuring your application responds effectively to unexpected scenarios

# Handled Vs. Unhandled Errors

When a flow is processing a message and a problem is encountered within a node, the execution of the flow will be transferred to any registered Catch node within the flow.

If a Catch node is present in the flow and the node where the error was originated is registered on it, the error is said to be handled, otherwise the error is said to be unhandled.

# Handled Errors

A Catch node will received the error thrown by the affected node and it will create an error property with the structure below, that will be injected into the msg before sending to its connected node.

error: {
  name: <Error Name>
  message: <Error Description>
  stack: <Stack trace of the error (used for support only)>
  source: {
    id: <node id where the error was originated>
    type: <node type where the error was originated>
    name: <node name>
  }
}

# Unhandled Errors

Any error not handled by a Catch node will result in a HTTP 500 Internal Server error being returned to the client.

The description of the error will be included in the body of the response.

# Scope of errors

It's crucial to recognize that the Catch node has visibility limited to errors within the specific flow (Designer tab) where they are defined, including their subflows. However, if an error occurs within a subflow defined in a different flow, it will not be visible to the Catch node of the invoking flow.

For instance, in the diagram below, the Catch node in flow_1 will handle only errors within its nodes and subflows but will not capture errors originating from the subflow defined in flow_2.