proxygen
proxygen::HTTPException Class Reference

#include <HTTPException.h>

Inheritance diagram for proxygen::HTTPException:
proxygen::Exception

Public Types

enum  Direction { Direction::INGRESS = 0, Direction::EGRESS, Direction::INGRESS_AND_EGRESS }
 

Public Member Functions

 HTTPException (Direction dir, const std::string &msg)
 
 HTTPException (const HTTPException &ex)
 
std::string describe () const
 
Direction getDirection () const
 
bool isIngressException () const
 
bool isEgressException () const
 
bool hasHttpStatusCode () const
 
void setHttpStatusCode (uint32_t statusCode)
 
uint32_t getHttpStatusCode () const
 
bool hasCodecStatusCode () const
 
void setCodecStatusCode (ErrorCode statusCode)
 
ErrorCode getCodecStatusCode () const
 
bool hasErrno () const
 
void setErrno (uint32_t e)
 
uint32_t getErrno () const
 
void setCurrentIngressBuf (std::unique_ptr< folly::IOBuf > buf)
 
std::unique_ptr< folly::IOBufmoveCurrentIngressBuf ()
 
void setPartialMsg (std::unique_ptr< HTTPMessage > partialMsg)
 
std::unique_ptr< HTTPMessagemovePartialMsg ()
 
- Public Member Functions inherited from proxygen::Exception
 Exception (std::string const &msg)
 
 Exception (const Exception &)
 
 Exception (Exception &other)
 
 Exception (Exception &&) noexcept
 
template<typename... Args>
 Exception (Args &&...args)
 
 ~Exception (void) noexceptoverride
 
const char * what (void) const noexceptoverride
 
void setCode (int code)
 
int getCode () const
 
bool hasProxygenError () const
 
void setProxygenError (ProxygenError proxygenError)
 
ProxygenError getProxygenError () const
 

Private Attributes

Direction dir_
 
uint32_t httpStatusCode_ {0}
 
folly::Optional< ErrorCodecodecStatusCode_
 
uint32_t errno_ {0}
 
std::unique_ptr< folly::IOBufcurrentIngressBuf_
 
std::unique_ptr< HTTPMessagepartialMsg_
 

Detailed Description

This class encapsulates the various errors that can occur on an http session. Errors can occur at various levels: the connection can be closed for reads and/or writes, the message body may fail to parse, or various protocol constraints may be violated.

Definition at line 26 of file HTTPException.h.

Member Enumeration Documentation

Indicates which direction of the data flow was affected by this exception. For instance, if a class receives HTTPException(INGRESS), then it should consider ingress callbacks finished (whether or not the underlying transport actually shut down). Likewise for HTTPException(EGRESS), the class should consider the write stream shut down. INGRESS_AND_EGRESS indicates both directions are finished.

Enumerator
INGRESS 
EGRESS 
INGRESS_AND_EGRESS 

Definition at line 36 of file HTTPException.h.

36  {
37  INGRESS = 0,
38  EGRESS,
39  INGRESS_AND_EGRESS,
40  };

Constructor & Destructor Documentation

proxygen::HTTPException::HTTPException ( Direction  dir,
const std::string msg 
)
inlineexplicit

Definition at line 42 of file HTTPException.h.

43  : Exception(msg),
44  dir_(dir) {}
Exception(std::string const &msg)
Definition: Exception.cpp:14
proxygen::HTTPException::HTTPException ( const HTTPException ex)
inline

Definition at line 46 of file HTTPException.h.

References currentIngressBuf_, describe(), partialMsg_, and string.

46  :
47  Exception(static_cast<const Exception&>(ex)),
48  dir_(ex.dir_),
49  httpStatusCode_(ex.httpStatusCode_),
50  codecStatusCode_(ex.codecStatusCode_),
51  errno_(ex.errno_) {
52  if (ex.currentIngressBuf_) {
53  currentIngressBuf_ = ex.currentIngressBuf_->clone();
54  }
55  if (ex.partialMsg_) {
56  partialMsg_ = std::make_unique<HTTPMessage>(*ex.partialMsg_.get());
57  }
58  }
Exception(std::string const &msg)
Definition: Exception.cpp:14
std::unique_ptr< HTTPMessage > partialMsg_
folly::Optional< ErrorCode > codecStatusCode_
std::unique_ptr< folly::IOBuf > currentIngressBuf_

Member Function Documentation

std::string proxygen::HTTPException::describe ( ) const

Returns a string representation of this exception. This function is intended for debugging and logging only. For the true exception string, use what()

Definition at line 18 of file HTTPException.cpp.

Referenced by HTTPException().

18  {
19  std::stringstream ss;
20  ss << *this;
21  return ss.str();
22 }
ErrorCode proxygen::HTTPException::getCodecStatusCode ( ) const
inline
Direction proxygen::HTTPException::getDirection ( ) const
inline

Definition at line 67 of file HTTPException.h.

References dir_.

Referenced by proxygen::HTTPTransaction::onError(), proxygen::operator<<(), and TEST_F().

67  {
68  return dir_;
69  }
uint32_t proxygen::HTTPException::getErrno ( ) const
inline

Definition at line 113 of file HTTPException.h.

References errno_.

113  {
114  return errno_;
115  }
uint32_t proxygen::HTTPException::getHttpStatusCode ( ) const
inline

Definition at line 90 of file HTTPException.h.

References httpStatusCode_.

Referenced by proxygen::SimpleController::getParseErrorHandler(), and proxygen::operator<<().

90  {
91  return httpStatusCode_;
92  }
bool proxygen::HTTPException::hasCodecStatusCode ( ) const
inline
bool proxygen::HTTPException::hasErrno ( ) const
inline

Definition at line 107 of file HTTPException.h.

References errno_.

107  {
108  return (errno_ != 0);
109  }
bool proxygen::HTTPException::hasHttpStatusCode ( ) const
inline

Definition at line 82 of file HTTPException.h.

References httpStatusCode_.

Referenced by proxygen::SimpleController::getParseErrorHandler().

82  {
83  return (httpStatusCode_ != 0);
84  }
bool proxygen::HTTPException::isEgressException ( ) const
inline
bool proxygen::HTTPException::isIngressException ( ) const
inline
std::unique_ptr<folly::IOBuf> proxygen::HTTPException::moveCurrentIngressBuf ( )
inline

Definition at line 121 of file HTTPException.h.

References currentIngressBuf_, and folly::gen::move.

121  {
123  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< folly::IOBuf > currentIngressBuf_
std::unique_ptr<HTTPMessage> proxygen::HTTPException::movePartialMsg ( )
inline

Definition at line 129 of file HTTPException.h.

References folly::gen::move, and partialMsg_.

129  {
130  return std::move(partialMsg_);
131  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< HTTPMessage > partialMsg_
void proxygen::HTTPException::setCurrentIngressBuf ( std::unique_ptr< folly::IOBuf buf)
inline

Definition at line 117 of file HTTPException.h.

References currentIngressBuf_, and folly::gen::move.

Referenced by proxygen::SPDYCodec::failSession(), proxygen::SPDYCodec::failStream(), and proxygen::HTTP1xCodec::onParserError().

117  {
119  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< folly::IOBuf > currentIngressBuf_
void proxygen::HTTPException::setErrno ( uint32_t  e)
inline

Definition at line 110 of file HTTPException.h.

References errno_.

110  {
111  errno_ = e;
112  }
void proxygen::HTTPException::setHttpStatusCode ( uint32_t  statusCode)
inline

Definition at line 86 of file HTTPException.h.

References httpStatusCode_, and statusCode.

Referenced by proxygen::SPDYCodec::failStream(), proxygen::HTTPChecks::onHeadersComplete(), proxygen::HTTP1xCodec::onParserError(), and TEST_F().

86  {
88  }
spdy::GoawayStatusCode statusCode
Definition: SPDYCodec.cpp:110
void proxygen::HTTPException::setPartialMsg ( std::unique_ptr< HTTPMessage partialMsg)
inline

Definition at line 125 of file HTTPException.h.

References folly::gen::move, and partialMsg_.

Referenced by proxygen::SPDYCodec::failStream(), and proxygen::HTTP1xCodec::onParserError().

125  {
126  partialMsg_ = std::move(partialMsg);
127  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< HTTPMessage > partialMsg_

Member Data Documentation

folly::Optional<ErrorCode> proxygen::HTTPException::codecStatusCode_
private

Definition at line 137 of file HTTPException.h.

Referenced by getCodecStatusCode(), hasCodecStatusCode(), and setCodecStatusCode().

std::unique_ptr<folly::IOBuf> proxygen::HTTPException::currentIngressBuf_
private

Definition at line 140 of file HTTPException.h.

Referenced by HTTPException(), moveCurrentIngressBuf(), and setCurrentIngressBuf().

Direction proxygen::HTTPException::dir_
private

Definition at line 135 of file HTTPException.h.

Referenced by getDirection(), isEgressException(), and isIngressException().

uint32_t proxygen::HTTPException::errno_ {0}
private

Definition at line 138 of file HTTPException.h.

Referenced by getErrno(), hasErrno(), and setErrno().

uint32_t proxygen::HTTPException::httpStatusCode_ {0}
private

Definition at line 136 of file HTTPException.h.

Referenced by getHttpStatusCode(), hasHttpStatusCode(), and setHttpStatusCode().

std::unique_ptr<HTTPMessage> proxygen::HTTPException::partialMsg_
private

Definition at line 142 of file HTTPException.h.

Referenced by HTTPException(), movePartialMsg(), and setPartialMsg().


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