ArmorIQ SDK

Error Recovery

Use fallbacks to handle failures gracefully.

Error Recovery

# ✓ Good - Graceful degradation
def invoke_with_fallback(client, mcp, action, token, params, fallback_value=None):
    try:
        result = client.invoke(mcp, action, token, params)
        if result["success"]:
            return result["data"]
        else:
            logger.warning(f"MCP failed: {result['error']}")
            return fallback_value
    except Exception as e:
        logger.error(f"Invoke failed: {e}")
        return fallback_value

# Usage
data = invoke_with_fallback(
    client, "data-mcp", "fetch", token, {},
    fallback_value=[]  # Empty list if fails
)

On this page