proxygen
AsyncSocketException.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include <folly/Format.h>
20 #include <folly/String.h>
21 
22 namespace folly {
23 
26  switch (type) {
27  case UNKNOWN:
28  return "Unknown async socket exception";
29  case NOT_OPEN:
30  return "Socket not open";
31  case ALREADY_OPEN:
32  return "Socket already open";
33  case TIMED_OUT:
34  return "Timed out";
35  case END_OF_FILE:
36  return "End of file";
37  case INTERRUPTED:
38  return "Interrupted";
39  case BAD_ARGS:
40  return "Invalid arguments";
41  case CORRUPTED_DATA:
42  return "Corrupted Data";
43  case INTERNAL_ERROR:
44  return "Internal error";
45  case NOT_SUPPORTED:
46  return "Not supported";
47  case INVALID_STATE:
48  return "Invalid state";
49  case SSL_ERROR:
50  return "SSL error";
51  case COULD_NOT_BIND:
52  return "Could not bind";
54  return "SASL handshake timeout";
55  case NETWORK_ERROR:
56  return "Network error";
58  return "Early data rejected";
59  default:
60  return "(Invalid exception type)";
61  }
62 }
63 
66  const std::string& message,
67  int errnoCopy) {
68  if (errnoCopy != 0) {
69  return sformat(
70  "AsyncSocketException: {}, type = {}, errno = {} ({})",
71  message,
73  errnoCopy,
74  errnoStr(errnoCopy));
75  } else {
76  return sformat(
77  "AsyncSocketException: {}, type = {}",
78  message,
80  }
81 }
82 
83 } // namespace folly
Definition: test.c:42
std::string sformat(StringPiece fmt, Args &&...args)
Definition: Format.h:280
PskType type
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
static std::string getMessage(AsyncSocketExceptionType type, const std::string &message, int errnoCopy)
static folly::StringPiece getExceptionTypeString(AsyncSocketExceptionType type)
fbstring errnoStr(int err)
Definition: String.cpp:463
const char * string
Definition: Conv.cpp:212