1/*
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
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
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
17 * under the License.
18 */
19
20#include <thrift/transport/TTransportException.h>
21#include <cstring>
22
23#include <thrift/thrift-config.h>
24
25using std::string;
26
27namespace apache {
28namespace thrift {
29namespace transport {
30
31const char* TTransportException::what() const noexcept {
32 if (message_.empty()) {
33 switch (type_) {
34 case UNKNOWN:
35 return "TTransportException: Unknown transport exception";
36 case NOT_OPEN:
37 return "TTransportException: Transport not open";
38 case TIMED_OUT:
39 return "TTransportException: Timed out";
40 case END_OF_FILE:
41 return "TTransportException: End of file";
42 case INTERRUPTED:
43 return "TTransportException: Interrupted";
44 case BAD_ARGS:
45 return "TTransportException: Invalid arguments";
46 case CORRUPTED_DATA:
47 return "TTransportException: Corrupted Data";
48 case INTERNAL_ERROR:
49 return "TTransportException: Internal error";
50 default:
51 return "TTransportException: (Invalid exception type)";
52 }
53 } else {
54 return message_.c_str();
55 }
56}
57}
58}
59} // apache::thrift::transport
60