proxygen
folly::AsyncSocketException Class Reference

#include <AsyncSocketException.h>

Inheritance diagram for folly::AsyncSocketException:
folly::SSLException wangle::FizzHandshakeException

Public Types

enum  AsyncSocketExceptionType {
  UNKNOWN = 0, NOT_OPEN = 1, ALREADY_OPEN = 2, TIMED_OUT = 3,
  END_OF_FILE = 4, INTERRUPTED = 5, BAD_ARGS = 6, CORRUPTED_DATA = 7,
  INTERNAL_ERROR = 8, NOT_SUPPORTED = 9, INVALID_STATE = 10, SSL_ERROR = 12,
  COULD_NOT_BIND = 13, SASL_HANDSHAKE_TIMEOUT = 14, NETWORK_ERROR = 15, EARLY_DATA_REJECTED = 16
}
 

Public Member Functions

 AsyncSocketException (AsyncSocketExceptionType type, const std::string &message, int errnoCopy=0)
 
AsyncSocketExceptionType getType () const noexcept
 
int getErrno () const noexcept
 

Static Protected Member Functions

static folly::StringPiece getExceptionTypeString (AsyncSocketExceptionType type)
 
static std::string getMessage (AsyncSocketExceptionType type, const std::string &message, int errnoCopy)
 

Protected Attributes

AsyncSocketExceptionType type_
 
int errno_
 

Detailed Description

Definition at line 26 of file AsyncSocketException.h.

Member Enumeration Documentation

Enumerator
UNKNOWN 
NOT_OPEN 
ALREADY_OPEN 
TIMED_OUT 
END_OF_FILE 
INTERRUPTED 
BAD_ARGS 
CORRUPTED_DATA 
INTERNAL_ERROR 
NOT_SUPPORTED 
INVALID_STATE 
SSL_ERROR 
COULD_NOT_BIND 
SASL_HANDSHAKE_TIMEOUT 
NETWORK_ERROR 
EARLY_DATA_REJECTED 

Definition at line 28 of file AsyncSocketException.h.

28  {
29  UNKNOWN = 0,
30  NOT_OPEN = 1,
31  ALREADY_OPEN = 2,
32  TIMED_OUT = 3,
33  END_OF_FILE = 4,
34  INTERRUPTED = 5,
35  BAD_ARGS = 6,
36  CORRUPTED_DATA = 7,
37  INTERNAL_ERROR = 8,
38  NOT_SUPPORTED = 9,
39  INVALID_STATE = 10,
40  SSL_ERROR = 12,
41  COULD_NOT_BIND = 13,
43  NETWORK_ERROR = 15,
45  };

Constructor & Destructor Documentation

folly::AsyncSocketException::AsyncSocketException ( AsyncSocketExceptionType  type,
const std::string message,
int  errnoCopy = 0 
)
inline

Definition at line 47 of file AsyncSocketException.h.

51  : std::runtime_error(getMessage(type, message, errnoCopy)),
52  type_(type),
53  errno_(errnoCopy) {}
Definition: test.c:42
PskType type
static std::string getMessage(AsyncSocketExceptionType type, const std::string &message, int errnoCopy)
AsyncSocketExceptionType type_

Member Function Documentation

int folly::AsyncSocketException::getErrno ( ) const
inlinenoexcept

Definition at line 59 of file AsyncSocketException.h.

References string, and type.

Referenced by folly::TEST().

59  {
60  return errno_;
61  }
StringPiece folly::AsyncSocketException::getExceptionTypeString ( AsyncSocketExceptionType  type)
staticprotected

get the string of exception type

Definition at line 24 of file AsyncSocketException.cpp.

References ALREADY_OPEN, BAD_ARGS, CORRUPTED_DATA, COULD_NOT_BIND, EARLY_DATA_REJECTED, END_OF_FILE, INTERNAL_ERROR, INTERRUPTED, INVALID_STATE, NETWORK_ERROR, NOT_OPEN, NOT_SUPPORTED, SASL_HANDSHAKE_TIMEOUT, SSL_ERROR, TIMED_OUT, and UNKNOWN.

Referenced by getMessage().

25  {
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 }
PskType type
std::string folly::AsyncSocketException::getMessage ( AsyncSocketExceptionType  type,
const std::string message,
int  errnoCopy 
)
staticprotected

Return a message based on the input.

Definition at line 64 of file AsyncSocketException.cpp.

References folly::errnoStr(), getExceptionTypeString(), and folly::sformat().

67  {
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 }
Definition: test.c:42
std::string sformat(StringPiece fmt, Args &&...args)
Definition: Format.h:280
PskType type
static folly::StringPiece getExceptionTypeString(AsyncSocketExceptionType type)
fbstring errnoStr(int err)
Definition: String.cpp:463
AsyncSocketExceptionType folly::AsyncSocketException::getType ( ) const
inlinenoexcept

Member Data Documentation

int folly::AsyncSocketException::errno_
protected

A copy of the errno.

Definition at line 78 of file AsyncSocketException.h.

AsyncSocketExceptionType folly::AsyncSocketException::type_
protected

Error code

Definition at line 75 of file AsyncSocketException.h.


The documentation for this class was generated from the following files: