File indexing completed on 2026-04-17 08:35:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_
0021 #define _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_ 1
0022
0023 #include <string>
0024
0025 namespace apache {
0026 namespace thrift {
0027 namespace protocol {
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 class TProtocolException : public apache::thrift::TException {
0038 public:
0039
0040
0041
0042 enum TProtocolExceptionType {
0043 UNKNOWN = 0,
0044 INVALID_DATA = 1,
0045 NEGATIVE_SIZE = 2,
0046 SIZE_LIMIT = 3,
0047 BAD_VERSION = 4,
0048 NOT_IMPLEMENTED = 5,
0049 DEPTH_LIMIT = 6
0050 };
0051
0052 TProtocolException() : apache::thrift::TException(), type_(UNKNOWN) {}
0053
0054 TProtocolException(TProtocolExceptionType type) : apache::thrift::TException(), type_(type) {}
0055
0056 TProtocolException(const std::string& message)
0057 : apache::thrift::TException(message), type_(UNKNOWN) {}
0058
0059 TProtocolException(TProtocolExceptionType type, const std::string& message)
0060 : apache::thrift::TException(message), type_(type) {}
0061
0062 ~TProtocolException() noexcept override = default;
0063
0064
0065
0066
0067
0068
0069
0070 TProtocolExceptionType getType() const { return type_; }
0071
0072 const char* what() const noexcept override {
0073 if (message_.empty()) {
0074 switch (type_) {
0075 case UNKNOWN:
0076 return "TProtocolException: Unknown protocol exception";
0077 case INVALID_DATA:
0078 return "TProtocolException: Invalid data";
0079 case NEGATIVE_SIZE:
0080 return "TProtocolException: Negative size";
0081 case SIZE_LIMIT:
0082 return "TProtocolException: Exceeded size limit";
0083 case BAD_VERSION:
0084 return "TProtocolException: Invalid version";
0085 case NOT_IMPLEMENTED:
0086 return "TProtocolException: Not implemented";
0087 case DEPTH_LIMIT:
0088 return "TProtocolException: Exceeded depth limit";
0089 default:
0090 return "TProtocolException: (Invalid exception type)";
0091 }
0092 } else {
0093 return message_.c_str();
0094 }
0095 }
0096
0097 protected:
0098
0099
0100
0101 TProtocolExceptionType type_;
0102 };
0103 }
0104 }
0105 }
0106
0107 #endif