Files
fastgpt-python-sdk/fastgpt_client/exceptions.py
Xin Wang 0495dd4676 Initial commit: FastGPT Python SDK Phase 1
Implement core infrastructure:

- BaseClientMixin with retry logic and validation
- FastGPTClient base class with httpx
- ChatClient with 11 chat operation methods
- AppClient for analytics and logs
- Custom exceptions (APIError, AuthenticationError, etc.)
- Package configuration (pyproject.toml, setup.py)
- Documentation (README.md, CLAUDE.md)
- Basic usage examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 14:39:33 +08:00

44 lines
1.0 KiB
Python

"""FastGPT Client Exceptions."""
class FastGPTError(Exception):
"""Base exception for all FastGPT errors."""
def __init__(self, message: str, status_code: int = None, response_data: dict = None):
self.message = message
self.status_code = status_code
self.response_data = response_data or {}
super().__init__(self.message)
class APIError(FastGPTError):
"""General API error (4xx, 5xx responses)."""
pass
class AuthenticationError(FastGPTError):
"""Authentication failed (401)."""
pass
class RateLimitError(FastGPTError):
"""Rate limit exceeded (429)."""
def __init__(self, message: str, retry_after: str = None, status_code: int = None, response_data: dict = None):
super().__init__(message, status_code, response_data)
self.retry_after = retry_after
class ValidationError(FastGPTError):
"""Invalid request parameters (422)."""
pass
class StreamParseError(FastGPTError):
"""Error parsing streaming response."""
pass