Decorator to handle API errors consistently.
(func)
| 24 | |
| 25 | |
| 26 | def api_error_handler(func): |
| 27 | """Decorator to handle API errors consistently.""" |
| 28 | |
| 29 | @wraps(func) |
| 30 | def wrapper(*args, **kwargs): |
| 31 | try: |
| 32 | return func(*args, **kwargs) |
| 33 | except httpx.HTTPStatusError as e: |
| 34 | logger.error(f"HTTP error occurred: {e}") |
| 35 | raise APIError(f"API request failed: {e.response.text}") |
| 36 | except httpx.RequestError as e: |
| 37 | logger.error(f"Request error occurred: {e}") |
| 38 | raise APIError(f"Request failed: {str(e)}") |
| 39 | |
| 40 | return wrapper |
| 41 | |
| 42 | |
| 43 | class MemoryClient: |
nothing calls this directly
no outgoing calls
no test coverage detected