Skip to main content
The Kubiya SDK provides a comprehensive exception hierarchy to help you handle errors gracefully and build resilient applications.

Overview

The SDK uses specialized exception classes to indicate different failure scenarios:
  • Core Exceptions: Authentication, connection, timeout errors
  • Resource Exceptions: Service-specific errors (graph, models, agents, etc.)
  • Validation Errors: Invalid parameters or data structures
  • API Errors: HTTP-level failures with status codes
Always catch specific exceptions before generic ones to handle different error types appropriately.

Exception Hierarchy

Quick Start

Core Exceptions

APIError

Generic API-level errors with HTTP status codes:

AuthenticationError

Authentication and authorization failures:

ConnectionError

Network connectivity issues:

TimeoutError

Request timeout failures:

RateLimitError

API rate limit exceeded:

Resource-Specific Exceptions

GraphError

Context Graph operation failures:

ModelError

LLM model management errors:

AgentError

Agent management errors:

PolicyError

Policy management errors:

WorkerError

Worker management errors:

IntegrationError

Integration management errors:

Error Handling Patterns

Try-Except-Finally

Multiple Exception Types

Retry with Exponential Backoff

Context Manager for Cleanup

Custom Error Handler

Validation Errors

Best Practices

1. Catch Specific Exceptions First

2. Log Errors Appropriately

3. Provide Context in Error Messages

4. Don’t Swallow Exceptions Silently

5. Clean Up Resources in Finally Blocks

Testing Error Handling

Next Steps

Best Practices

SDK best practices guide

Control Plane Client

Learn the Control Plane client services

Troubleshooting

Common issues and solutions

Examples

Code examples and recipes