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_TAPPLICATIONEXCEPTION_H_
21 #define _THRIFT_TAPPLICATIONEXCEPTION_H_ 1
23 #include <thrift/Thrift.h>
32 class TApplicationException
: public TException
{
35 * Error codes for the various types of exceptions.
37 enum TApplicationExceptionType
{
40 INVALID_MESSAGE_TYPE
= 2,
41 WRONG_METHOD_NAME
= 3,
46 INVALID_TRANSFORM
= 8,
48 UNSUPPORTED_CLIENT_TYPE
= 10
51 TApplicationException() : TException(), type_(UNKNOWN
) {}
53 TApplicationException(TApplicationExceptionType type
) : TException(), type_(type
) {}
55 TApplicationException(const std::string
& message
) : TException(message
), type_(UNKNOWN
) {}
57 TApplicationException(TApplicationExceptionType type
, const std::string
& message
)
58 : TException(message
), type_(type
) {}
60 ~TApplicationException() noexcept override
= default;
63 * Returns an error code that provides information about the type of error
68 TApplicationExceptionType
getType() const { return type_
; }
70 const char* what() const noexcept override
{
71 if (message_
.empty()) {
74 return "TApplicationException: Unknown application exception";
76 return "TApplicationException: Unknown method";
77 case INVALID_MESSAGE_TYPE
:
78 return "TApplicationException: Invalid message type";
79 case WRONG_METHOD_NAME
:
80 return "TApplicationException: Wrong method name";
82 return "TApplicationException: Bad sequence identifier";
84 return "TApplicationException: Missing result";
86 return "TApplicationException: Internal error";
88 return "TApplicationException: Protocol error";
89 case INVALID_TRANSFORM
:
90 return "TApplicationException: Invalid transform";
91 case INVALID_PROTOCOL
:
92 return "TApplicationException: Invalid protocol";
93 case UNSUPPORTED_CLIENT_TYPE
:
94 return "TApplicationException: Unsupported client type";
96 return "TApplicationException: (Invalid exception type)";
99 return message_
.c_str();
103 uint32_t read(protocol::TProtocol
* iprot
);
104 uint32_t write(protocol::TProtocol
* oprot
) const;
110 TApplicationExceptionType type_
;
115 #endif // #ifndef _THRIFT_TAPPLICATIONEXCEPTION_H_