| 1 |
|
| 2 |
|
| 3 |
from typing import Any, Dict, Optional |
| 4 |
|
| 5 |
|
| 6 |
class ApiError(Exception): |
| 7 |
headers: Optional[Dict[str, str]] |
| 8 |
status_code: Optional[int] |
| 9 |
body: Any |
| 10 |
|
| 11 |
def __init__( |
| 12 |
self, |
| 13 |
*, |
| 14 |
headers: Optional[Dict[str, str]] = None, |
| 15 |
status_code: Optional[int] = None, |
| 16 |
body: Any = None, |
| 17 |
) -> None: |
| 18 |
self.headers = headers |
| 19 |
self.status_code = status_code |
| 20 |
self.body = body |
| 21 |
|
| 22 |
def __str__(self) -> str: |
| 23 |
return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}" |