Skip to main content
Platform custom exceptions provide domain-specific error handling for services instead of generic Python exceptions. Platform custom exceptions provide domain-specific error handling for services instead of generic Python exceptions.
The user catches typed platform exceptions to return actionable errors instead of generic HTTP failures.

Quick Start

1

Import Exceptions

2

Raise Domain-Specific Errors


How It Works


Exception Types

Base Exception

The PlatformError base class provides common functionality:

Resource Errors

Handle resource-related errors with specific exceptions:

Authentication & Authorization

Secure your platform with auth-specific exceptions:

Data Validation

Validate input with clear error messages:

FastAPI Integration

Handle platform exceptions in FastAPI applications:

Common Patterns

Service Layer Pattern

Use exceptions consistently across services:

Error Context

Include helpful context in exception messages:

Exception Chaining

Chain exceptions to preserve original error context:

Best Practices

Always use the most specific exception type available. This helps with error handling and debugging.
Provide clear, actionable error messages that help users understand what went wrong.
Each exception type maps to a specific HTTP status code. Use consistent exception handlers in your FastAPI applications.
Take advantage of the exception hierarchy. Catch PlatformError to handle all platform exceptions, or catch specific types for targeted handling.

Platform Dependencies

Manage platform service dependencies

API Error Handling

Best practices for API error handling