"""Exceptions."""from__future__importannotationsfromsocketimporttimeoutasTimeoutErrorfromtypesimportTracebackTypefromtypingimportTYPE_CHECKING,TypeVarfromamqpimportChannelError,ConnectionError,ResourceErrorifTYPE_CHECKING:fromkombu.asynchronous.httpimportResponse__all__=('reraise','KombuError','OperationalError','NotBoundError','MessageStateError','TimeoutError','LimitExceeded','ConnectionLimitExceeded','ChannelLimitExceeded','ConnectionError','ChannelError','VersionMismatch','SerializerNotInstalled','ResourceError','SerializationError','EncodeError','DecodeError','HttpError','InconsistencyError',)BaseExceptionType=TypeVar('BaseExceptionType',bound=BaseException)defreraise(tp:type[BaseExceptionType],value:BaseExceptionType,tb:TracebackType|None=None)->BaseExceptionType:"""Reraise exception."""ifvalue.__traceback__isnottb:raisevalue.with_traceback(tb)raisevalueclassKombuError(Exception):"""Common subclass for all Kombu exceptions."""
[文档]classOperationalError(KombuError):"""Recoverable message transport connection error."""
classSerializationError(KombuError):"""Failed to serialize/deserialize content."""classEncodeError(SerializationError):"""Cannot encode object."""classDecodeError(SerializationError):"""Cannot decode object."""classNotBoundError(KombuError):"""Trying to call channel dependent method on unbound entity."""classMessageStateError(KombuError):"""The message has already been acknowledged."""classLimitExceeded(KombuError):"""Limit exceeded."""classConnectionLimitExceeded(LimitExceeded):"""Maximum number of simultaneous connections exceeded."""classChannelLimitExceeded(LimitExceeded):"""Maximum number of simultaneous channels exceeded."""classVersionMismatch(KombuError):"""Library dependency version mismatch."""classSerializerNotInstalled(KombuError):"""Support for the requested serialization type is not installed."""classContentDisallowed(SerializerNotInstalled):"""Consumer does not allow this content-type."""classInconsistencyError(ConnectionError):"""Data or environment has been found to be inconsistent. Depending on the cause it may be possible to retry the operation. """classHttpError(Exception):"""HTTP Client Error."""def__init__(self,code:int,message:str|None=None,response:Response|None=None)->None:self.code=codeself.message=messageself.response=responsesuper().__init__(code,message,response)def__str__(self)->str:return'HTTP {0.code}: {0.message}'.format(self)