proxygen
ExceptionWrapperTest.cpp File Reference
#include <stdexcept>
#include <folly/Conv.h>
#include <folly/ExceptionWrapper.h>
#include <folly/portability/GTest.h>

Go to the source code of this file.

Classes

class  AbstractIntException
 
class  IntException
 

Functions

template<typename T >
Tfrom_eptr (std::exception_ptr &eptr)
 
 TEST (ExceptionWrapper, nothrow)
 
 TEST (ExceptionWrapper, throw_test)
 
 TEST (ExceptionWrapper, throw_with_nested)
 
 TEST (ExceptionWrapper, members)
 
 TEST (ExceptionWrapper, try_and_catch_test)
 
 TEST (ExceptionWrapper, with_exception_test)
 
 TEST (ExceptionWrapper, get_or_make_exception_ptr_test)
 
 TEST (ExceptionWrapper, from_exception_ptr_empty)
 
 TEST (ExceptionWrapper, from_exception_ptr_exn)
 
 TEST (ExceptionWrapper, from_exception_ptr_any)
 
 TEST (ExceptionWrapper, with_exception_ptr_empty)
 
 TEST (ExceptionWrapper, with_shared_ptr_test)
 
 TEST (ExceptionWrapper, with_exception_ptr_exn_test)
 
 TEST (ExceptionWrapper, with_exception_ptr_any_test)
 
 TEST (ExceptionWrapper, with_non_std_exception_test)
 
 TEST (ExceptionWrapper, with_exception_ptr_any_nil_test)
 
 TEST (ExceptionWrapper, with_exception_deduction)
 
 TEST (ExceptionWrapper, with_exception_deduction_exn_const)
 
 TEST (ExceptionWrapper, with_exception_deduction_wrap_const_exn_const)
 
 TEST (ExceptionWrapper, with_exception_deduction_returning)
 
 TEST (ExceptionWrapper, with_exception_deduction_functor_lvalue)
 
 TEST (ExceptionWrapper, non_std_exception_test)
 
 TEST (ExceptionWrapper, exceptionStr)
 
 TEST (ExceptionWrapper, throwException_noException)
 
 TEST (ExceptionWrapper, implicitConstruction)
 
 TEST (ExceptionWrapper, base_derived_non_std_exception_test)
 
 TEST (ExceptionWrapper, handle_std_exception)
 
 TEST (ExceptionWrapper, handle_std_exception_unhandled)
 
 TEST (ExceptionWrapper, handle_std_exception_propagated)
 
 TEST (ExceptionWrapper, handle_non_std_exception_small)
 
 TEST (ExceptionWrapper, handle_non_std_exception_big)
 
 TEST (ExceptionWrapper, handle_non_std_exception_rethrow_base_derived)
 
 TEST (ExceptionWrapper, self_swap_test)
 

Variables

static const std::string kExceptionClassName
 
static const std::string kRuntimeErrorClassName
 
static const std::string kIntExceptionClassName
 
static const std::string kIntClassName = demangle(typeid(int)).toStdString()
 

Function Documentation

template<typename T >
T& from_eptr ( std::exception_ptr &  eptr)

Definition at line 55 of file ExceptionWrapperTest.cpp.

References folly::T.

55  {
56  try {
58  } catch (T& e) {
59  return e;
60  } catch (...) {
61  throw std::logic_error("impossible");
62  }
63 }
#define T(v)
Definition: http_parser.c:233
void rethrow_exception(std::exception_ptr ep)
TEST ( ExceptionWrapper  ,
throw_test   
)

Definition at line 74 of file ExceptionWrapperTest.cpp.

References EXPECT_EQ, and string.

74  {
75  std::runtime_error e("payload");
76  auto ew = make_exception_wrapper<std::runtime_error>(e);
77 
78  std::vector<exception_wrapper> container;
79  container.push_back(ew);
80 
81  try {
82  container[0].throw_exception();
83  } catch (std::runtime_error& err) {
84  std::string expected = "payload";
85  std::string actual = err.what();
86  EXPECT_EQ(expected, actual);
87  }
88 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
const char * string
Definition: Conv.cpp:212
TEST ( ExceptionWrapper  ,
throw_with_nested   
)

Definition at line 91 of file ExceptionWrapperTest.cpp.

References ADD_FAILURE, and EXPECT_STREQ.

91  {
92  auto ew = make_exception_wrapper<std::runtime_error>("inner");
93  try {
94  ew.throw_with_nested(std::runtime_error("outer"));
95  ADD_FAILURE();
96  } catch (std::runtime_error& outer) {
97  EXPECT_STREQ(outer.what(), "outer");
98  try {
99  std::rethrow_if_nested(outer);
100  ADD_FAILURE();
101  } catch (std::runtime_error& inner) {
102  EXPECT_STREQ(inner.what(), "inner");
103  }
104  }
105 }
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:1995
#define ADD_FAILURE()
Definition: gtest.h:1808
TEST ( ExceptionWrapper  ,
members   
)

Definition at line 107 of file ExceptionWrapperTest.cpp.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, and kRuntimeErrorClassName.

107  {
108  auto ew = exception_wrapper();
109  EXPECT_FALSE(bool(ew));
110  EXPECT_EQ(ew.what(), "");
111  EXPECT_EQ(ew.class_name(), "");
112  ew = make_exception_wrapper<std::runtime_error>("payload");
113  EXPECT_TRUE(bool(ew));
114  EXPECT_EQ(ew.what(), kRuntimeErrorClassName + ": payload");
115  EXPECT_EQ(ew.class_name(), kRuntimeErrorClassName);
116 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const std::string kRuntimeErrorClassName
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
try_and_catch_test   
)

Definition at line 118 of file ExceptionWrapperTest.cpp.

References folly::exception_wrapper::class_name(), EXPECT_EQ, EXPECT_FALSE, EXPECT_THROW, EXPECT_TRUE, folly::exception_wrapper::is_compatible_with(), kExceptionClassName, kRuntimeErrorClassName, string, and folly::exception_wrapper::what().

118  {
119  std::string expected = "payload";
120 
121  // Catch rightmost matching exception type
122  exception_wrapper ew = try_and_catch<std::exception, std::runtime_error>(
123  [=]() { throw std::runtime_error(expected); });
124  EXPECT_TRUE(bool(ew));
125  EXPECT_EQ(ew.what(), kRuntimeErrorClassName + ": payload");
127  auto rep = ew.is_compatible_with<std::runtime_error>();
128  EXPECT_TRUE(rep);
129 
130  // Changing order is like catching in wrong order. Beware of this in your
131  // code.
132  auto ew2 = try_and_catch<std::runtime_error, std::exception>(
133  [=]() { throw std::runtime_error(expected); });
134  EXPECT_TRUE(bool(ew2));
135  // We are catching a std::exception, not std::runtime_error.
136  // But, we can still get the actual type if we want it.
137  rep = ew2.is_compatible_with<std::runtime_error>();
138  EXPECT_TRUE(rep);
139 
140  // Catches even if not rightmost.
141  auto ew3 = try_and_catch<std::exception, std::runtime_error>(
142  []() { throw std::exception(); });
143  EXPECT_TRUE(bool(ew3));
144  EXPECT_EQ(ew3.what(), kExceptionClassName + ": std::exception");
145  EXPECT_EQ(ew3.class_name(), kExceptionClassName);
146  rep = ew3.is_compatible_with<std::runtime_error>();
147  EXPECT_FALSE(rep);
148 
149  // If does not catch, throws.
150  EXPECT_THROW(
151  try_and_catch<std::runtime_error>([]() { throw std::exception(); }),
152  std::exception);
153 }
folly::fbstring what() const
static const std::string kExceptionClassName
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
bool is_compatible_with() const noexcept
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static const std::string kRuntimeErrorClassName
folly::fbstring class_name() const
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
const char * string
Definition: Conv.cpp:212
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
with_exception_test   
)

Definition at line 155 of file ExceptionWrapperTest.cpp.

References folly::exception_wrapper::class_name(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, AbstractIntException::getInt(), ie, kIntExceptionClassName, folly::exception_wrapper::what(), and folly::exception_wrapper::with_exception().

155  {
156  int expected = 23;
157 
158  // This works, and doesn't slice.
159  exception_wrapper ew = try_and_catch<std::exception, std::runtime_error>(
160  [=]() { throw IntException(expected); });
161  EXPECT_TRUE(bool(ew));
162  EXPECT_EQ(ew.what(), kIntExceptionClassName + ": int == 23");
165  [&](const IntException& ie) { EXPECT_EQ(ie.getInt(), expected); }));
166 
167  // I can try_and_catch a non-copyable base class. This will use
168  // std::exception_ptr internally.
169  exception_wrapper ew2 = try_and_catch<AbstractIntException>(
170  [=]() { throw IntException(expected); });
171  EXPECT_TRUE(bool(ew2));
172  EXPECT_EQ(ew2.what(), kIntExceptionClassName + ": int == 23");
173  EXPECT_EQ(ew2.class_name(), kIntExceptionClassName);
174  bool res = ew2.with_exception([&](AbstractIntException& ie) {
175  EXPECT_EQ(ie.getInt(), expected);
176  EXPECT_TRUE(dynamic_cast<IntException*>(&ie));
177  });
178  EXPECT_TRUE(res);
179 
180  // Test with const this. If this compiles and does not crash due to
181  // infinite loop when it runs, it succeeds.
182  const exception_wrapper& cew = ew;
183  EXPECT_TRUE(
184  cew.with_exception([&](const IntException& /* ie */) { SUCCEED(); }));
185 
186  // Test with empty ew.
187  exception_wrapper empty_ew;
188  EXPECT_FALSE(
189  empty_ew.with_exception([&](const std::exception& /* ie */) { FAIL(); }));
190 
191  // Testing with const exception_wrapper; sanity check first:
192  EXPECT_FALSE(cew.with_exception([&](const std::runtime_error&) {}));
193  EXPECT_FALSE(cew.with_exception([&](const int&) {}));
194  // This won't even compile. You can't use a function which takes a
195  // non-const reference with a const exception_wrapper.
196  /*
197  EXPECT_FALSE(cew.with_exception([&](std::runtime_error&) {}));
198  EXPECT_FALSE(cew.with_exception([&](int&) {}));
199  */
200 }
folly::fbstring what() const
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
folly::fbstring class_name() const
static const std::string kIntExceptionClassName
auto ie
virtual int getInt() const =0
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
get_or_make_exception_ptr_test   
)

Definition at line 202 of file ExceptionWrapperTest.cpp.

References EXPECT_FALSE, EXPECT_THROW, and folly::exception_wrapper::to_exception_ptr().

202  {
203  int expected = 23;
204 
205  // This works, and doesn't slice.
206  exception_wrapper ew = try_and_catch<std::exception, std::runtime_error>(
207  [=]() { throw IntException(expected); });
208  std::exception_ptr eptr = ew.to_exception_ptr();
209  EXPECT_THROW(std::rethrow_exception(eptr), IntException);
210 
211  // I can try_and_catch a non-copyable base class. This will use
212  // std::exception_ptr internally.
213  exception_wrapper ew2 = try_and_catch<AbstractIntException>(
214  [=]() { throw IntException(expected); });
215  eptr = ew2.to_exception_ptr();
216  EXPECT_THROW(std::rethrow_exception(eptr), IntException);
217 
218  // Test with const this.
219  const exception_wrapper& cew = ew;
220  eptr = cew.to_exception_ptr();
221  EXPECT_THROW(std::rethrow_exception(eptr), IntException);
222 
223  // Test with empty ew.
224  exception_wrapper empty_ew;
225  eptr = empty_ew.to_exception_ptr();
226  EXPECT_FALSE(eptr);
227 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
std::exception_ptr const & to_exception_ptr() noexcept
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
from_exception_ptr_empty   
)

Definition at line 229 of file ExceptionWrapperTest.cpp.

References EXPECT_FALSE, and folly::exception_wrapper::from_exception_ptr().

229  {
230  auto ep = std::exception_ptr();
231  auto ew = exception_wrapper::from_exception_ptr(ep);
232  EXPECT_FALSE(bool(ew));
233 }
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
from_exception_ptr_exn   
)

Definition at line 235 of file ExceptionWrapperTest.cpp.

References EXPECT_EQ, EXPECT_TRUE, and folly::exception_wrapper::from_exception_ptr().

235  {
236  auto ep = std::make_exception_ptr(std::runtime_error("foo"));
237  auto ew = exception_wrapper::from_exception_ptr(ep);
238  EXPECT_TRUE(bool(ew));
239  EXPECT_EQ(ep, ew.to_exception_ptr());
240  EXPECT_TRUE(ew.is_compatible_with<std::runtime_error>());
241 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ExceptionWrapper  ,
from_exception_ptr_any   
)

Definition at line 243 of file ExceptionWrapperTest.cpp.

References EXPECT_EQ, EXPECT_TRUE, and folly::exception_wrapper::from_exception_ptr().

243  {
244  auto ep = std::make_exception_ptr<int>(12);
245  auto ew = exception_wrapper::from_exception_ptr(ep);
246  EXPECT_TRUE(bool(ew));
247  EXPECT_EQ(ep, ew.to_exception_ptr());
248  EXPECT_TRUE(ew.is_compatible_with<int>());
249 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ExceptionWrapper  ,
with_exception_ptr_empty   
)

Definition at line 251 of file ExceptionWrapperTest.cpp.

References EXPECT_EQ, EXPECT_FALSE, and folly::exception_wrapper::none().

251  {
252  auto ew = exception_wrapper(std::exception_ptr());
253  EXPECT_EQ(exception_wrapper::none(), ew.type());
254  EXPECT_FALSE(bool(ew));
255  EXPECT_EQ(nullptr, ew.get_exception());
256  EXPECT_EQ(nullptr, ew.get_exception<std::exception>());
257  EXPECT_EQ(nullptr, ew.get_exception<int>());
258  EXPECT_FALSE(ew.has_exception_ptr());
259  EXPECT_EQ(nullptr, ew.to_exception_ptr());
260  EXPECT_FALSE(ew.has_exception_ptr());
261  EXPECT_EQ("", ew.class_name());
262  EXPECT_EQ("", ew.what());
263  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
264  EXPECT_FALSE(ew.is_compatible_with<int>());
265  EXPECT_DEATH(ew.throw_exception(), "empty folly::exception_wrapper");
266 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
constexpr None none
Definition: Optional.h:87
TEST ( ExceptionWrapper  ,
with_shared_ptr_test   
)

Definition at line 268 of file ExceptionWrapperTest.cpp.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_NE, EXPECT_STREQ, EXPECT_THROW, EXPECT_TRUE, folly::gen::move, and folly::exception_wrapper::none().

268  {
269  auto ew = exception_wrapper(std::runtime_error("foo"));
270  EXPECT_TRUE(bool(ew));
271  EXPECT_EQ(typeid(std::runtime_error), ew.type());
272  EXPECT_NE(nullptr, ew.get_exception());
273  EXPECT_NE(nullptr, ew.get_exception<std::exception>());
274  EXPECT_STREQ("foo", ew.get_exception<std::exception>()->what());
275  EXPECT_EQ(nullptr, ew.get_exception<int>());
276  EXPECT_FALSE(ew.has_exception_ptr());
277  EXPECT_NE(nullptr, ew.to_exception_ptr());
278  EXPECT_TRUE(ew.has_exception_ptr());
279  EXPECT_EQ(kRuntimeErrorClassName, ew.class_name());
280  EXPECT_EQ(kRuntimeErrorClassName + ": foo", ew.what());
281  EXPECT_TRUE(ew.is_compatible_with<std::exception>());
282  EXPECT_TRUE(ew.is_compatible_with<std::runtime_error>());
283  EXPECT_FALSE(ew.is_compatible_with<int>());
284  EXPECT_THROW(ew.throw_exception(), std::runtime_error);
285 
287  EXPECT_FALSE(bool(ew));
288  EXPECT_EQ(exception_wrapper::none(), ew.type());
289  EXPECT_EQ(nullptr, ew.get_exception());
290  EXPECT_EQ(nullptr, ew.get_exception<std::exception>());
291  EXPECT_EQ(nullptr, ew.get_exception<int>());
292  EXPECT_EQ(nullptr, ew.to_exception_ptr());
293  EXPECT_EQ("", ew.class_name());
294  EXPECT_EQ("", ew.what());
295  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
296  EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
297  EXPECT_FALSE(ew.is_compatible_with<int>());
298 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static const std::string kRuntimeErrorClassName
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:1995
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
constexpr None none
Definition: Optional.h:87
TEST ( ExceptionWrapper  ,
with_exception_ptr_exn_test   
)

Definition at line 300 of file ExceptionWrapperTest.cpp.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_NE, EXPECT_STREQ, EXPECT_THROW, EXPECT_TRUE, folly::gen::move, and folly::exception_wrapper::none().

300  {
301  auto ep = std::make_exception_ptr(std::runtime_error("foo"));
302  auto ew = exception_wrapper(ep, from_eptr<std::runtime_error>(ep));
303  EXPECT_TRUE(bool(ew));
304  EXPECT_EQ(typeid(std::runtime_error), ew.type());
305  EXPECT_NE(nullptr, ew.get_exception());
306  EXPECT_NE(nullptr, ew.get_exception<std::exception>());
307  EXPECT_STREQ("foo", ew.get_exception<std::exception>()->what());
308  EXPECT_EQ(nullptr, ew.get_exception<int>());
309  EXPECT_TRUE(ew.has_exception_ptr());
310  EXPECT_EQ(ep, ew.to_exception_ptr());
311  EXPECT_TRUE(ew.has_exception_ptr());
312  EXPECT_EQ(kRuntimeErrorClassName, ew.class_name());
313  EXPECT_EQ(kRuntimeErrorClassName + ": foo", ew.what());
314  EXPECT_TRUE(ew.is_compatible_with<std::exception>());
315  EXPECT_TRUE(ew.is_compatible_with<std::runtime_error>());
316  EXPECT_FALSE(ew.is_compatible_with<int>());
317  EXPECT_THROW(ew.throw_exception(), std::runtime_error);
318 
320  EXPECT_FALSE(bool(ew));
321  EXPECT_EQ(exception_wrapper::none(), ew.type());
322  EXPECT_EQ(nullptr, ew.get_exception());
323  EXPECT_EQ(nullptr, ew.get_exception<std::exception>());
324  EXPECT_EQ(nullptr, ew.get_exception<int>());
325  EXPECT_EQ(nullptr, ew.to_exception_ptr());
326  EXPECT_EQ("", ew.class_name());
327  EXPECT_EQ("", ew.what());
328  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
329  EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
330  EXPECT_FALSE(ew.is_compatible_with<int>());
331 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static const std::string kRuntimeErrorClassName
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:1995
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
constexpr None none
Definition: Optional.h:87
TEST ( ExceptionWrapper  ,
with_exception_ptr_any_test   
)

Definition at line 333 of file ExceptionWrapperTest.cpp.

References folly::demangle(), EXPECT_EQ, EXPECT_FALSE, EXPECT_NE, EXPECT_THROW, EXPECT_TRUE, and folly::gen::move.

333  {
334  auto ep = std::make_exception_ptr<int>(12);
335  auto ew = exception_wrapper(ep, from_eptr<int>(ep));
336  EXPECT_TRUE(bool(ew));
337  EXPECT_EQ(nullptr, ew.get_exception());
338  EXPECT_EQ(nullptr, ew.get_exception<std::exception>());
339  EXPECT_NE(nullptr, ew.get_exception<int>());
340  EXPECT_EQ(12, *ew.get_exception<int>());
341  EXPECT_TRUE(ew.has_exception_ptr());
342  EXPECT_EQ(ep, ew.to_exception_ptr());
343  EXPECT_TRUE(ew.has_exception_ptr());
344  EXPECT_EQ(demangle(typeid(int)), ew.class_name());
345  EXPECT_EQ(demangle(typeid(int)), ew.what());
346  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
347  EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
348  EXPECT_TRUE(ew.is_compatible_with<int>());
349  EXPECT_THROW(ew.throw_exception(), int);
350 
352  EXPECT_FALSE(bool(ew));
353  EXPECT_EQ(nullptr, ew.get_exception());
354  EXPECT_EQ(nullptr, ew.get_exception<std::exception>());
355  EXPECT_EQ(nullptr, ew.get_exception<int>());
356  EXPECT_EQ(nullptr, ew.to_exception_ptr());
357  EXPECT_FALSE(ew.has_exception_ptr());
358  EXPECT_EQ("", ew.class_name());
359  EXPECT_EQ("", ew.what());
360  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
361  EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
362  EXPECT_FALSE(ew.is_compatible_with<int>());
363 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fbstring demangle(const char *name)
Definition: Demangle.cpp:111
TEST ( ExceptionWrapper  ,
with_non_std_exception_test   
)

Definition at line 365 of file ExceptionWrapperTest.cpp.

References folly::demangle(), EXPECT_EQ, EXPECT_FALSE, EXPECT_NE, EXPECT_THROW, EXPECT_TRUE, folly::in_place(), and folly::gen::move.

365  {
366  auto ew = exception_wrapper(folly::in_place, 42);
367  EXPECT_TRUE(bool(ew));
368  EXPECT_EQ(nullptr, ew.get_exception());
369  EXPECT_EQ(nullptr, ew.get_exception<std::exception>());
370  EXPECT_NE(nullptr, ew.get_exception<int>());
371  EXPECT_EQ(42, *ew.get_exception<int>());
372  EXPECT_TRUE(ew.has_exception_ptr());
373  EXPECT_EQ(demangle(typeid(int)), ew.class_name());
374  EXPECT_EQ(demangle(typeid(int)), ew.what());
375  EXPECT_NE(nullptr, ew.to_exception_ptr());
376  EXPECT_TRUE(ew.has_exception_ptr());
377  EXPECT_EQ(demangle(typeid(int)), ew.class_name());
378  EXPECT_EQ(demangle(typeid(int)), ew.what());
379  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
380  EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
381  EXPECT_TRUE(ew.is_compatible_with<int>());
382  EXPECT_THROW(ew.throw_exception(), int);
383 
385  EXPECT_FALSE(bool(ew));
386  EXPECT_EQ(nullptr, ew.get_exception());
387  EXPECT_EQ(nullptr, ew.get_exception<std::exception>());
388  EXPECT_EQ(nullptr, ew.get_exception<int>());
389  EXPECT_EQ(nullptr, ew.to_exception_ptr());
390  EXPECT_FALSE(ew.has_exception_ptr());
391  EXPECT_EQ("", ew.class_name());
392  EXPECT_EQ("", ew.what());
393  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
394  EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
395  EXPECT_FALSE(ew.is_compatible_with<int>());
396 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
in_place_tag in_place(in_place_tag={})
Definition: Utility.h:235
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
fbstring demangle(const char *name)
Definition: Demangle.cpp:111
TEST ( ExceptionWrapper  ,
with_exception_ptr_any_nil_test   
)

Definition at line 398 of file ExceptionWrapperTest.cpp.

References EXPECT_EQ, EXPECT_FALSE, EXPECT_NE, EXPECT_THROW, EXPECT_TRUE, and folly::gen::move.

398  {
399  auto ep = std::make_exception_ptr<int>(12);
400  auto ew = exception_wrapper(ep); // concrete type is erased
401  EXPECT_TRUE(bool(ew));
402  EXPECT_EQ(nullptr, ew.get_exception());
403  EXPECT_EQ(nullptr, ew.get_exception<std::exception>());
404  EXPECT_NE(nullptr, ew.get_exception<int>());
405  EXPECT_EQ(12, *ew.get_exception<int>());
406  EXPECT_EQ(ep, ew.to_exception_ptr());
407  EXPECT_EQ("<unknown exception>", ew.class_name()); // because concrete type is
408  // erased
409  EXPECT_EQ("<unknown exception>", ew.what());
410  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
411  EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
412  EXPECT_TRUE(ew.is_compatible_with<int>());
413  EXPECT_THROW(ew.throw_exception(), int);
414 
416  EXPECT_FALSE(bool(ew));
417  EXPECT_EQ(nullptr, ew.get_exception());
418  EXPECT_EQ(nullptr, ew.get_exception<std::exception>());
419  EXPECT_EQ(nullptr, ew.get_exception<int>());
420  EXPECT_EQ(nullptr, ew.to_exception_ptr());
421  EXPECT_EQ("", ew.class_name());
422  EXPECT_EQ("", ew.what());
423  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
424  EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
425  EXPECT_FALSE(ew.is_compatible_with<int>());
426 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
with_exception_deduction   
)

Definition at line 428 of file ExceptionWrapperTest.cpp.

References EXPECT_FALSE, and EXPECT_TRUE.

428  {
429  auto ew = make_exception_wrapper<std::runtime_error>("hi");
430  EXPECT_TRUE(ew.with_exception([](std::runtime_error&) {}));
431  EXPECT_TRUE(ew.with_exception([](std::exception&) {}));
432  EXPECT_FALSE(ew.with_exception([](std::logic_error&) {}));
433 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
with_exception_deduction_exn_const   
)

Definition at line 435 of file ExceptionWrapperTest.cpp.

References EXPECT_FALSE, and EXPECT_TRUE.

435  {
436  auto ew = make_exception_wrapper<std::runtime_error>("hi");
437  EXPECT_TRUE(ew.with_exception([](const std::runtime_error&) {}));
438  EXPECT_TRUE(ew.with_exception([](const std::exception&) {}));
439  EXPECT_FALSE(ew.with_exception([](const std::logic_error&) {}));
440 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
with_exception_deduction_wrap_const_exn_const   
)

Definition at line 442 of file ExceptionWrapperTest.cpp.

References EXPECT_FALSE, and EXPECT_TRUE.

442  {
443  const auto cew = make_exception_wrapper<std::runtime_error>("hi");
444  EXPECT_TRUE(cew.with_exception([](const std::runtime_error&) {}));
445  EXPECT_TRUE(cew.with_exception([](const std::exception&) {}));
446  EXPECT_FALSE(cew.with_exception([](const std::logic_error&) {}));
447 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
with_exception_deduction_returning   
)

Definition at line 449 of file ExceptionWrapperTest.cpp.

References EXPECT_FALSE, EXPECT_TRUE, and folly::T.

449  {
450  auto ew = make_exception_wrapper<std::runtime_error>("hi");
451  EXPECT_TRUE(ew.with_exception([](std::runtime_error&) { return 3; }));
452  EXPECT_TRUE(ew.with_exception([](std::exception&) { return "hello"; }));
453  EXPECT_FALSE(ew.with_exception([](std::logic_error&) { return nullptr; }));
454 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
with_exception_deduction_functor_lvalue   
)

Definition at line 463 of file ExceptionWrapperTest.cpp.

References EXPECT_FALSE, and EXPECT_TRUE.

463  {
464  auto ew = make_exception_wrapper<std::runtime_error>("hi");
465  EXPECT_TRUE(ew.with_exception(r_to_l([](std::runtime_error&) {})));
466  EXPECT_TRUE(ew.with_exception(r_to_l([](std::exception&) {})));
467  EXPECT_FALSE(ew.with_exception(r_to_l([](std::logic_error&) {})));
468 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
non_std_exception_test   
)

Definition at line 470 of file ExceptionWrapperTest.cpp.

References folly::exception_wrapper::class_name(), EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, i, folly::exception_wrapper::is_compatible_with(), kIntClassName, folly::exception_wrapper::throw_exception(), and folly::exception_wrapper::what().

470  {
471  int expected = 17;
472 
473  exception_wrapper ew =
474  try_and_catch<std::exception, int>([=]() { throw expected; });
475  EXPECT_TRUE(bool(ew));
476  EXPECT_FALSE(ew.is_compatible_with<std::exception>());
477  EXPECT_TRUE(ew.is_compatible_with<int>());
480  // non-std::exception types are supported, but the only way to
481  // access their value is to explicity rethrow and catch it.
482  try {
483  ew.throw_exception();
484  } catch /* nolint */ (int& i) {
485  EXPECT_EQ(i, expected);
486  }
487 }
folly::fbstring what() const
bool is_compatible_with() const noexcept
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
folly::fbstring class_name() const
static const std::string kIntClassName
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST ( ExceptionWrapper  ,
exceptionStr   
)

Definition at line 489 of file ExceptionWrapperTest.cpp.

References folly::exceptionStr(), and EXPECT_EQ.

489  {
490  auto ew = make_exception_wrapper<std::runtime_error>("argh");
492 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
fbstring exceptionStr(const std::exception &e)
static const std::string kRuntimeErrorClassName
TEST ( ExceptionWrapper  ,
throwException_noException   
)

Definition at line 494 of file ExceptionWrapperTest.cpp.

References EXPECT_THROW, and folly::exception_wrapper::throw_exception().

494  {
496  ASSERT_DEATH(ew.throw_exception(), "empty folly::exception_wrapper");
497 }
TEST ( ExceptionWrapper  ,
implicitConstruction   
)

Definition at line 506 of file ExceptionWrapperTest.cpp.

506  {
507  // Try with both lvalue and rvalue references
508  TestException e;
509  testEW(e);
510  testEW(TestException());
511 }
TEST ( ExceptionWrapper  ,
base_derived_non_std_exception_test   
)

Definition at line 527 of file ExceptionWrapperTest.cpp.

References data_, and EXPECT_TRUE.

527  {
528  auto ew = testNonStdException();
529  EXPECT_TRUE(ew.type() == typeid(DerivedException));
530  EXPECT_TRUE(ew.with_exception([](const DerivedException&) {}));
531 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ExceptionWrapper  ,
handle_std_exception   
)

Definition at line 545 of file ExceptionWrapperTest.cpp.

References ADD_FAILURE, EXPECT_THROW, EXPECT_TRUE, and handled.

545  {
546  auto ep = std::make_exception_ptr(std::runtime_error{"hello world"});
547  exception_wrapper const ew_eptr(ep, from_eptr<std::runtime_error>(ep));
548  exception_wrapper const ew_small(std::runtime_error{"hello world"});
549  exception_wrapper const ew_big(BigRuntimeError{"hello world"});
550 
551  bool handled = false;
552  auto expect_runtime_error_yes_catch_all = [&](const exception_wrapper& ew) {
553  ew.handle(
554  [](const std::logic_error&) { ADD_FAILURE(); },
555  [&](const std::runtime_error&) { handled = true; },
556  [](const std::exception&) { ADD_FAILURE(); },
557  [](...) { ADD_FAILURE(); });
558  };
559 
560  expect_runtime_error_yes_catch_all(ew_eptr);
561  EXPECT_TRUE(handled);
562  handled = false;
563  expect_runtime_error_yes_catch_all(ew_small);
564  EXPECT_TRUE(handled);
565  handled = false;
566  expect_runtime_error_yes_catch_all(ew_big);
567  EXPECT_TRUE(handled);
568  handled = false;
569 
570  auto expect_runtime_error_no_catch_all = [&](const exception_wrapper& ew) {
571  ew.handle(
572  [](const std::logic_error&) { ADD_FAILURE(); },
573  [&](const std::runtime_error&) { handled = true; },
574  [](const std::exception&) { ADD_FAILURE(); });
575  };
576 
577  expect_runtime_error_no_catch_all(ew_eptr);
578  EXPECT_TRUE(handled);
579  handled = false;
580  expect_runtime_error_no_catch_all(ew_small);
581  EXPECT_TRUE(handled);
582  handled = false;
583  expect_runtime_error_no_catch_all(ew_big);
584  EXPECT_TRUE(handled);
585  handled = false;
586 
587  auto expect_runtime_error_catch_non_std = [&](const exception_wrapper& ew) {
588  ew.handle(
589  [](const std::logic_error&) { ADD_FAILURE(); },
590  [&](const std::runtime_error&) { handled = true; },
591  [](const std::exception&) { ADD_FAILURE(); },
592  [](const int&) { ADD_FAILURE(); });
593  };
594 
595  expect_runtime_error_catch_non_std(ew_eptr);
596  EXPECT_TRUE(handled);
597  handled = false;
598  expect_runtime_error_catch_non_std(ew_small);
599  EXPECT_TRUE(handled);
600  handled = false;
601  expect_runtime_error_catch_non_std(ew_big);
602  EXPECT_TRUE(handled);
603  handled = false;
604 
605  // Test that an exception thrown from one handler is not caught by an
606  // outer handler:
607  auto expect_runtime_error_rethrow = [&](const exception_wrapper& ew) {
608  ew.handle(
609  [](const std::logic_error&) { ADD_FAILURE(); },
610  [&](const std::runtime_error& e) {
611  handled = true;
612  throw e;
613  },
614  [](const std::exception&) { ADD_FAILURE(); });
615  };
616 
617  EXPECT_THROW(expect_runtime_error_rethrow(ew_eptr), std::runtime_error);
618  EXPECT_TRUE(handled);
619  handled = false;
620  EXPECT_THROW(expect_runtime_error_rethrow(ew_small), std::runtime_error);
621  EXPECT_TRUE(handled);
622  handled = false;
623  EXPECT_THROW(expect_runtime_error_rethrow(ew_big), std::runtime_error);
624  EXPECT_TRUE(handled);
625 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
volatile bool handled
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define ADD_FAILURE()
Definition: gtest.h:1808
TEST ( ExceptionWrapper  ,
handle_std_exception_unhandled   
)

Definition at line 627 of file ExceptionWrapperTest.cpp.

References ADD_FAILURE, EXPECT_TRUE, and handled.

627  {
628  auto ep = std::make_exception_ptr(std::exception{});
629  exception_wrapper const ew_eptr(ep, from_eptr<std::exception>(ep));
630  exception_wrapper const ew_small(std::exception{});
631 
632  bool handled = false;
633  auto expect_runtime_error_yes_catch_all = [&](const exception_wrapper& ew) {
634  ew.handle(
635  [](const std::logic_error&) { ADD_FAILURE(); },
636  [](const std::runtime_error&) { ADD_FAILURE(); },
637  [&](...) { handled = true; });
638  };
639 
640  expect_runtime_error_yes_catch_all(ew_eptr);
641  EXPECT_TRUE(handled);
642  handled = false;
643  expect_runtime_error_yes_catch_all(ew_small);
644  EXPECT_TRUE(handled);
645 }
volatile bool handled
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define ADD_FAILURE()
Definition: gtest.h:1808
TEST ( ExceptionWrapper  ,
handle_std_exception_propagated   
)

Definition at line 647 of file ExceptionWrapperTest.cpp.

References ADD_FAILURE, folly::exception_wrapper::handle(), and SUCCEED.

647  {
648  auto ep = std::make_exception_ptr(std::runtime_error{"hello world"});
649  exception_wrapper const ew_eptr(ep, from_eptr<std::runtime_error>(ep));
650  exception_wrapper const ew_small(std::runtime_error{"hello world"});
651  exception_wrapper const ew_big(BigRuntimeError{"hello world"});
652 
653  try {
654  ew_eptr.handle();
655  } catch (const std::runtime_error&) {
656  SUCCEED();
657  } catch (const std::exception&) {
658  ADD_FAILURE();
659  }
660 
661  try {
662  ew_small.handle();
663  } catch (const std::runtime_error&) {
664  SUCCEED();
665  } catch (const std::exception&) {
666  ADD_FAILURE();
667  }
668 
669  try {
670  ew_big.handle();
671  } catch (const std::runtime_error&) {
672  SUCCEED();
673  } catch (const std::exception&) {
674  ADD_FAILURE();
675  }
676 }
void handle(CatchFns...fns)
#define SUCCEED()
Definition: gtest.h:1831
#define ADD_FAILURE()
Definition: gtest.h:1808
TEST ( ExceptionWrapper  ,
handle_non_std_exception_small   
)

Definition at line 678 of file ExceptionWrapperTest.cpp.

References ADD_FAILURE, EXPECT_TRUE, handled, and folly::in_place().

678  {
679  auto ep = std::make_exception_ptr(42);
680  exception_wrapper const ew_eptr1(ep);
681  exception_wrapper const ew_eptr2(ep, from_eptr<int>(ep));
682  exception_wrapper const ew_small(folly::in_place, 42);
683  bool handled = false;
684 
685  auto expect_int_yes_catch_all = [&](const exception_wrapper& ew) {
686  ew.handle(
687  [](const std::exception&) { ADD_FAILURE(); },
688  [&](...) { handled = true; });
689  };
690 
691  expect_int_yes_catch_all(ew_eptr1);
692  EXPECT_TRUE(handled);
693  handled = false;
694  expect_int_yes_catch_all(ew_eptr2);
695  EXPECT_TRUE(handled);
696  handled = false;
697  expect_int_yes_catch_all(ew_small);
698  EXPECT_TRUE(handled);
699  handled = false;
700 
701  auto expect_int_no_catch_all = [&](const exception_wrapper& ew) {
702  ew.handle(
703  [](const std::exception&) { ADD_FAILURE(); },
704  [&](const int&) { handled = true; });
705  };
706 
707  expect_int_no_catch_all(ew_eptr1);
708  EXPECT_TRUE(handled);
709  handled = false;
710  expect_int_no_catch_all(ew_eptr2);
711  EXPECT_TRUE(handled);
712  handled = false;
713  expect_int_no_catch_all(ew_small);
714  EXPECT_TRUE(handled);
715  handled = false;
716 
717  auto expect_int_no_catch_all_2 = [&](const exception_wrapper& ew) {
718  ew.handle(
719  [&](const int&) { handled = true; },
720  [](const std::exception&) { ADD_FAILURE(); });
721  };
722 
723  expect_int_no_catch_all_2(ew_eptr1);
724  EXPECT_TRUE(handled);
725  handled = false;
726  expect_int_no_catch_all_2(ew_eptr2);
727  EXPECT_TRUE(handled);
728  handled = false;
729  expect_int_no_catch_all_2(ew_small);
730  EXPECT_TRUE(handled);
731 }
volatile bool handled
in_place_tag in_place(in_place_tag={})
Definition: Utility.h:235
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define ADD_FAILURE()
Definition: gtest.h:1808
TEST ( ExceptionWrapper  ,
handle_non_std_exception_big   
)

Definition at line 733 of file ExceptionWrapperTest.cpp.

References ADD_FAILURE, EXPECT_THROW, EXPECT_TRUE, handled, and folly::in_place().

733  {
734  auto ep = std::make_exception_ptr(BigNonStdError{});
735  exception_wrapper const ew_eptr1(ep);
736  exception_wrapper const ew_eptr2(ep, from_eptr<BigNonStdError>(ep));
737  exception_wrapper const ew_big(folly::in_place, BigNonStdError{});
738  bool handled = false;
739 
740  auto expect_int_yes_catch_all = [&](const exception_wrapper& ew) {
741  ew.handle(
742  [](const std::exception&) { ADD_FAILURE(); },
743  [&](...) { handled = true; });
744  };
745 
746  expect_int_yes_catch_all(ew_eptr1);
747  EXPECT_TRUE(handled);
748  handled = false;
749  expect_int_yes_catch_all(ew_eptr2);
750  EXPECT_TRUE(handled);
751  handled = false;
752  expect_int_yes_catch_all(ew_big);
753  EXPECT_TRUE(handled);
754  handled = false;
755 
756  auto expect_int_no_catch_all = [&](const exception_wrapper& ew) {
757  ew.handle(
758  [](const std::exception&) { ADD_FAILURE(); },
759  [&](const BigNonStdError&) { handled = true; });
760  };
761 
762  expect_int_no_catch_all(ew_eptr1);
763  EXPECT_TRUE(handled);
764  handled = false;
765  expect_int_no_catch_all(ew_eptr2);
766  EXPECT_TRUE(handled);
767  handled = false;
768  expect_int_no_catch_all(ew_big);
769  EXPECT_TRUE(handled);
770  handled = false;
771 
772  auto expect_int_no_catch_all_2 = [&](const exception_wrapper& ew) {
773  ew.handle(
774  [&](const BigNonStdError&) { handled = true; },
775  [](const std::exception&) { ADD_FAILURE(); });
776  };
777 
778  expect_int_no_catch_all_2(ew_eptr1);
779  EXPECT_TRUE(handled);
780  handled = false;
781  expect_int_no_catch_all_2(ew_eptr2);
782  EXPECT_TRUE(handled);
783  handled = false;
784  expect_int_no_catch_all_2(ew_big);
785  EXPECT_TRUE(handled);
786  handled = false;
787 
788  EXPECT_THROW(
789  expect_int_no_catch_all_2(exception_wrapper{folly::in_place, 42}), int);
790 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
volatile bool handled
in_place_tag in_place(in_place_tag={})
Definition: Utility.h:235
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
#define ADD_FAILURE()
Definition: gtest.h:1808
TEST ( ExceptionWrapper  ,
handle_non_std_exception_rethrow_base_derived   
)

Definition at line 792 of file ExceptionWrapperTest.cpp.

References EXPECT_THROW, EXPECT_TRUE, and handled.

792  {
793  auto ew = testNonStdException();
794  bool handled = false;
795  EXPECT_THROW(
796  ew.handle(
797  [&](const DerivedException& e) {
798  handled = true;
799  throw e;
800  },
801  [](const BaseException&) { ADD_FAILURE(); }),
802  DerivedException);
803  EXPECT_TRUE(handled);
804  handled = false;
805  EXPECT_THROW(
806  ew.handle(
807  [&](const DerivedException& e) {
808  handled = true;
809  throw e;
810  },
811  [](...) { ADD_FAILURE(); }),
812  DerivedException);
813  EXPECT_TRUE(handled);
814 }
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:1843
volatile bool handled
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
TEST ( ExceptionWrapper  ,
self_swap_test   
)

Definition at line 816 of file ExceptionWrapperTest.cpp.

References EXPECT_EQ, folly::gen::move, folly::swap(), and folly::exception_wrapper::what().

816  {
817  exception_wrapper ew(std::runtime_error("hello world"));
818  folly::swap(ew, ew);
819  EXPECT_EQ(kRuntimeErrorClassName + ": hello world", ew.what());
820  auto& ew2 = ew;
821  ew = std::move(ew2); // should not crash
822 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static const std::string kRuntimeErrorClassName
void swap(exception_wrapper &a, exception_wrapper &b) noexcept

Variable Documentation

const std::string kExceptionClassName
static
Initial value:
=
demangle(typeid(std::exception)).toStdString()
std::basic_string< E, T, A > toStdString() const
Definition: FBString.h:1227
fbstring demangle(const char *name)
Definition: Demangle.cpp:111

Definition at line 46 of file ExceptionWrapperTest.cpp.

Referenced by TEST().

const std::string kIntClassName = demangle(typeid(int)).toStdString()
static

Definition at line 52 of file ExceptionWrapperTest.cpp.

Referenced by TEST().

const std::string kIntExceptionClassName
static
Initial value:
=
std::basic_string< E, T, A > toStdString() const
Definition: FBString.h:1227
fbstring demangle(const char *name)
Definition: Demangle.cpp:111

Definition at line 50 of file ExceptionWrapperTest.cpp.

Referenced by TEST().

const std::string kRuntimeErrorClassName
static
Initial value:
=
demangle(typeid(std::runtime_error)).toStdString()
std::basic_string< E, T, A > toStdString() const
Definition: FBString.h:1227
fbstring demangle(const char *name)
Definition: Demangle.cpp:111

Definition at line 48 of file ExceptionWrapperTest.cpp.

Referenced by TEST().