proxygen
folly::FormatKeyNotFoundException Class Reference

#include <Format.h>

Inheritance diagram for folly::FormatKeyNotFoundException:

Public Member Functions

 FormatKeyNotFoundException (StringPiece key)
 
char const * key () const noexcept
 

Static Private Attributes

static constexpr StringPiece const kMessagePrefix = "format key not found: "
 

Detailed Description

Exception class thrown when a format key is not found in the given associative container keyed by strings. We inherit std::out_of_range for compatibility with callers that expect exception to be thrown directly by std::map or std::unordered_map.

Having the key be at the end of the message string, we can access it by simply adding its offset to what(). Not storing separate std::string key makes the exception type small and noexcept-copyable like std::out_of_range, and therefore able to fit in-situ in exception_wrapper.

Definition at line 322 of file Format.h.

Constructor & Destructor Documentation

folly::FormatKeyNotFoundException::FormatKeyNotFoundException ( StringPiece  key)
explicit

Definition at line 422 of file Format.cpp.

References kMessagePrefix.

423  : std::out_of_range(kMessagePrefix.str() + key.str()) {}
std::string str() const
Definition: Range.h:591
char const * key() const noexcept
Definition: Format.h:326
static constexpr StringPiece const kMessagePrefix
Definition: Format.h:331

Member Function Documentation

char const* folly::FormatKeyNotFoundException::key ( ) const
inlinenoexcept

Definition at line 326 of file Format.h.

Referenced by TEST().

326  {
327  return what() + kMessagePrefix.size();
328  }
constexpr size_type size() const
Definition: Range.h:431
static constexpr StringPiece const kMessagePrefix
Definition: Format.h:331

Member Data Documentation

constexpr StringPiece const folly::FormatKeyNotFoundException::kMessagePrefix = "format key not found: "
staticprivate

Definition at line 331 of file Format.h.

Referenced by FormatKeyNotFoundException().


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