# Copyright (c) Meta Platforms, Inc. and affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from enum import Enum, Flag from typing import Any from thrift.python.exceptions import Error as Error, LibraryError as LibraryError class TransportErrorType(Enum): UNKNOWN: TransportErrorType = ... NOT_OPEN: TransportErrorType = ... ALREADY_OPEN: TransportErrorType = ... TIMED_OUT: TransportErrorType = ... END_OF_FILE: TransportErrorType = ... INTERRUPTED: TransportErrorType = ... BAD_ARGS: TransportErrorType = ... CORRUPTED_DATA: TransportErrorType = ... INTERNAL_ERROR: TransportErrorType = ... NOT_SUPPORTED: TransportErrorType = ... INVALID_STATE: TransportErrorType = ... INVALID_FRAME_SIZE: TransportErrorType = ... SSL_ERROR: TransportErrorType = ... COULD_NOT_BIND: TransportErrorType = ... NETWORK_ERROR: TransportErrorType = ... @property def value(self) -> int: ... class TransportOptions(Flag): CHANNEL_IS_VALID: TransportOptions = ... @property def value(self) -> int: ... class ApplicationErrorType(Enum): UNKNOWN: ApplicationErrorType = ... UNKNOWN_METHOD: ApplicationErrorType = ... INVALID_MESSAGE_TYPE: ApplicationErrorType = ... WRONG_METHOD_NAME: ApplicationErrorType = ... BAD_SEQUENCE_ID: ApplicationErrorType = ... MISSING_RESULT: ApplicationErrorType = ... INTERNAL_ERROR: ApplicationErrorType = ... PROTOCOL_ERROR: ApplicationErrorType = ... INVALID_TRANSFORM: ApplicationErrorType = ... INVALID_PROTOCOL: ApplicationErrorType = ... UNSUPPORTED_CLIENT_TYPE: ApplicationErrorType = ... LOADSHEDDING: ApplicationErrorType = ... TIMEOUT: ApplicationErrorType = ... INJECTED_FAILURE: ApplicationErrorType = ... @property def value(self) -> int: ... class ProtocolErrorType(Enum): UNKNOWN: ProtocolErrorType = ... INVALID_DATA: ProtocolErrorType = ... NEGATIVE_SIZE: ProtocolErrorType = ... BAD_VERSION: ProtocolErrorType = ... NOT_IMPLEMENTED: ProtocolErrorType = ... MISSING_REQUIRED_FIELD: ProtocolErrorType = ... @property def value(self) -> int: ... class GeneratedError(Error): def __repr__(self) -> str: ... class ApplicationError(Error): def __init__(self, type: ApplicationErrorType, message: str) -> None: ... type: ApplicationErrorType message: str class ProtocolError(LibraryError): def __init__(self, type: ProtocolErrorType, message: str) -> None: ... type: ProtocolErrorType message: str class TransportError(LibraryError): def __init__( self, type: TransportErrorType, message: str, errno: int, options: TransportOptions, *args: Any, ) -> None: ... type: TransportErrorType options: TransportOptions message: str errno: int