2 * Copyright 2017 Facebook, Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <folly/Range.h>
26 class AsyncSocketException : public std::runtime_error {
28 enum AsyncSocketExceptionType {
42 SASL_HANDSHAKE_TIMEOUT = 14,
44 EARLY_DATA_REJECTED = 16,
48 AsyncSocketExceptionType type,
49 const std::string& message,
51 : std::runtime_error(getMessage(type, message, errnoCopy)),
56 AsyncSocketExceptionType type_;
58 /** A copy of the errno. */
61 AsyncSocketExceptionType getType() const noexcept {
65 int getErrno() const noexcept {
70 /** get the string of exception type */
71 static folly::StringPiece getExceptionTypeString(
72 AsyncSocketExceptionType type);
74 /** Return a message based on the input. */
75 static std::string getMessage(
76 AsyncSocketExceptionType type,
77 const std::string& message,