proxygen
Exception.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
12 #include <folly/Conv.h>
14 #include <string>
15 #include <utility>
16 
17 namespace proxygen {
18 
22 class Exception : public std::exception {
23  public:
24  explicit Exception(std::string const& msg);
25  Exception(const Exception&);
26  Exception(Exception& other) : Exception(folly::as_const(other)) {} // @nolint
28 
29  template <typename... Args>
30  explicit Exception(Args&&... args)
31  : msg_(folly::to<std::string>(std::forward<Args>(args)...)), code_(0) {}
32 
33  ~Exception(void) noexcept override {}
34 
35  // std::exception methods
36  const char* what(void) const noexcept override;
37 
38  // Accessors for code
39  void setCode(int code) { code_ = code; }
40 
41  int getCode() const { return code_; }
42 
43  // Accessors for ProxygenError
44  bool hasProxygenError() const { return (proxygenError_ != kErrorNone); }
45 
46  void setProxygenError(ProxygenError proxygenError) {
47  proxygenError_ = proxygenError;
48  }
49 
51 
52  private:
54  int code_;
56 };
57 
58 }
ProxygenError getProxygenError() const
Definition: Exception.h:50
Exception(std::string const &msg)
Definition: Exception.cpp:14
STL namespace.
void setProxygenError(ProxygenError proxygenError)
Definition: Exception.h:46
Exception(Exception &other)
Definition: Exception.h:26
~Exception(void) noexceptoverride
Definition: Exception.h:33
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
const std::string msg_
Definition: Exception.h:53
void setCode(int code)
Definition: Exception.h:39
std::enable_if< detail::is_chrono_conversion< Tgt, Src >::value, Tgt >::type to(const Src &value)
Definition: Conv.h:677
int getCode() const
Definition: Exception.h:41
bool hasProxygenError() const
Definition: Exception.h:44
ProxygenError proxygenError_
Definition: Exception.h:55
const char * string
Definition: Conv.cpp:212
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::detail::as_const_fn as_const
Exception(Args &&...args)
Definition: Exception.h:30
const char * what(void) const noexceptoverride
Definition: Exception.cpp:26