2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the
7
* "License"); you may not use this file except in compliance
8
* with the License. You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing,
13
* software distributed under the License is distributed on an
14
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
* KIND, either express or implied. See the License for the
16
* specific language governing permissions and limitations
20
#ifndef _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_
21
#define _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_ 1
25
namespace apache { namespace thrift { namespace protocol {
28
* Class to encapsulate all the possible types of protocol errors that may
29
* occur in various protocol systems. This provides a sort of generic
30
* wrapper around the vague UNIX E_ error codes that lets a common code
31
* base of error handling to be used for various types of protocols, i.e.
35
class TProtocolException : public apache::thrift::TException {
39
* Error codes for the various types of exceptions.
41
enum TProtocolExceptionType
50
TProtocolException() :
51
apache::thrift::TException(),
54
TProtocolException(TProtocolExceptionType type) :
55
apache::thrift::TException(),
58
TProtocolException(const std::string& message) :
59
apache::thrift::TException(message),
62
TProtocolException(TProtocolExceptionType type, const std::string& message) :
63
apache::thrift::TException(message),
66
virtual ~TProtocolException() throw() {}
69
* Returns an error code that provides information about the type of error
74
TProtocolExceptionType getType() {
78
virtual const char* what() const throw() {
79
if (message_.empty()) {
81
case UNKNOWN : return "TProtocolException: Unknown protocol exception";
82
case INVALID_DATA : return "TProtocolException: Invalid data";
83
case NEGATIVE_SIZE : return "TProtocolException: Negative size";
84
case SIZE_LIMIT : return "TProtocolException: Exceeded size limit";
85
case BAD_VERSION : return "TProtocolException: Invalid version";
86
case NOT_IMPLEMENTED : return "TProtocolException: Not implemented";
87
default : return "TProtocolException: (Invalid exception type)";
90
return message_.c_str();
98
TProtocolExceptionType type_;
102
}}} // apache::thrift::protocol
104
#endif // #ifndef _THRIFT_PROTOCOL_TPROTOCOLEXCEPTION_H_