MCPcopy Create free account
hub / github.com/apache/thrift / TProtocolException

Class TProtocolException

lib/cpp/src/thrift/protocol/TProtocolException.h:37–102  ·  view source on GitHub ↗

* Class to encapsulate all the possible types of protocol errors that may * occur in various protocol systems. This provides a sort of generic * wrapper around the vague UNIX E_ error codes that lets a common code * base of error handling to be used for various types of protocols, i.e. * pipes etc. * */

Source from the content-addressed store, hash-verified

35 *
36 */
37class TProtocolException : public apache::thrift::TException {
38public:
39 /**
40 * Error codes for the various types of exceptions.
41 */
42 enum TProtocolExceptionType {
43 UNKNOWN = 0,
44 INVALID_DATA = 1,
45 NEGATIVE_SIZE = 2,
46 SIZE_LIMIT = 3,
47 BAD_VERSION = 4,
48 NOT_IMPLEMENTED = 5,
49 DEPTH_LIMIT = 6
50 };
51
52 TProtocolException() : apache::thrift::TException(), type_(UNKNOWN) {}
53
54 TProtocolException(TProtocolExceptionType type) : apache::thrift::TException(), type_(type) {}
55
56 TProtocolException(const std::string& message)
57 : apache::thrift::TException(message), type_(UNKNOWN) {}
58
59 TProtocolException(TProtocolExceptionType type, const std::string& message)
60 : apache::thrift::TException(message), type_(type) {}
61
62 ~TProtocolException() noexcept override = default;
63
64 /**
65 * Returns an error code that provides information about the type of error
66 * that has occurred.
67 *
68 * @return Error code
69 */
70 TProtocolExceptionType getType() const { return type_; }
71
72 const char* what() const noexcept override {
73 if (message_.empty()) {
74 switch (type_) {
75 case UNKNOWN:
76 return "TProtocolException: Unknown protocol exception";
77 case INVALID_DATA:
78 return "TProtocolException: Invalid data";
79 case NEGATIVE_SIZE:
80 return "TProtocolException: Negative size";
81 case SIZE_LIMIT:
82 return "TProtocolException: Exceeded size limit";
83 case BAD_VERSION:
84 return "TProtocolException: Invalid version";
85 case NOT_IMPLEMENTED:
86 return "TProtocolException: Not implemented";
87 case DEPTH_LIMIT:
88 return "TProtocolException: Exceeded depth limit";
89 default:
90 return "TProtocolException: (Invalid exception type)";
91 }
92 } else {
93 return message_.c_str();
94 }

Callers 15

TJSONProtocol.cppFile · 0.70
getTypeIDForTypeNameFunction · 0.70
readSyntaxCharFunction · 0.70
hexValFunction · 0.70
writeJSONBase64Method · 0.70
writeJSONIntegerMethod · 0.70
writeJSONDoubleMethod · 0.70
readJSONStringMethod · 0.70
readJSONBase64Method · 0.70
readJSONIntegerMethod · 0.70
readJSONDoubleMethod · 0.70
readMessageBeginMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected