11 lines
464 B
Python
11 lines
464 B
Python
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
|