ForcePilot/backend/package/yuxi/channel/adapters/http_error.py

11 lines
464 B
Python
Raw Normal View History

2026-07-15 12:30:58 +08:00
from yuxi.channel.exceptions import ChannelErrorClassification
class HttpErrorClassifier:
def classify(self, status_code: int | None, exc: Exception | None = None) -> ChannelErrorClassification:
if status_code == 429:
return ChannelErrorClassification.RATE_LIMITED
if status_code is not None and 400 <= status_code < 500:
return ChannelErrorClassification.PERMANENT
return ChannelErrorClassification.RETRYABLE