proxygen
ExceptionTracerTest.cpp File Reference
#include <iostream>
#include <stdexcept>
#include <folly/experimental/exception_tracer/ExceptionTracer.h>

Go to the source code of this file.

Functions

void bar ()
 
void dumpExceptions (const char *prefix)
 
void foo ()
 
void baz ()
 
void testExceptionPtr1 ()
 
void testExceptionPtr2 ()
 
int main (int, char *[])
 

Function Documentation

void bar ( )

Definition at line 22 of file ExceptionTracerTest.cpp.

Referenced by baz(), folly::symbolizer::test::comparator(), foo(), folly::symbolizer::test::ElfCacheTest::SetUp(), folly::symbolizer::test::TEST(), and testExceptionPtr1().

22  {
23  throw std::runtime_error("hello");
24 }
void baz ( )

Definition at line 48 of file ExceptionTracerTest.cpp.

References bar(), and dumpExceptions().

Referenced by main().

48  {
49  try {
50  try {
51  bar();
52  } catch (...) {
53  dumpExceptions("baz: simple catch");
54  throw;
55  }
56  } catch (const std::exception& e) {
57  dumpExceptions("baz: catch rethrown exception");
58  throw "hello";
59  }
60 }
void dumpExceptions(const char *prefix)
void bar()
void dumpExceptions ( const char *  prefix)

Definition at line 27 of file ExceptionTracerTest.cpp.

References folly::exception_tracer::getCurrentExceptions().

Referenced by baz(), foo(), testExceptionPtr1(), and testExceptionPtr2().

27  {
28  std::cerr << "--- " << prefix << "\n";
30  for (auto& exc : exceptions) {
31  std::cerr << exc << "\n";
32  }
33 }
bool prefix(Cursor &c, uint32_t expected)
std::vector< ExceptionInfo > getCurrentExceptions()
void foo ( )

Definition at line 35 of file ExceptionTracerTest.cpp.

References bar(), and dumpExceptions().

Referenced by main().

35  {
36  try {
37  try {
38  bar();
39  } catch (const std::exception& e) {
40  dumpExceptions("foo: simple catch");
41  bar();
42  }
43  } catch (const std::exception& e) {
44  dumpExceptions("foo: catch, exception thrown from previous catch block");
45  }
46 }
void dumpExceptions(const char *prefix)
void bar()
int main ( int  ,
char *  [] 
)

Definition at line 92 of file ExceptionTracerTest.cpp.

References baz(), foo(), testExceptionPtr1(), and testExceptionPtr2().

92  {
93  foo();
96  baz();
97  // no return because baz() is [[noreturn]]
98 }
void testExceptionPtr1()
void testExceptionPtr2()
void baz()
void foo()
void testExceptionPtr1 ( )

Definition at line 62 of file ExceptionTracerTest.cpp.

References bar(), and dumpExceptions().

Referenced by main().

62  {
63  std::exception_ptr exc;
64  try {
65  bar();
66  } catch (...) {
67  exc = std::current_exception();
68  }
69 
70  try {
72  } catch (...) {
73  dumpExceptions("std::rethrow_exception 1");
74  }
75 }
void dumpExceptions(const char *prefix)
void rethrow_exception(std::exception_ptr ep)
void bar()
void testExceptionPtr2 ( )

Definition at line 77 of file ExceptionTracerTest.cpp.

References dumpExceptions().

Referenced by main().

77  {
78  std::exception_ptr exc;
79  try {
80  throw std::out_of_range("x");
81  } catch (...) {
82  exc = std::current_exception();
83  }
84 
85  try {
87  } catch (...) {
88  dumpExceptions("std::rethrow_exception 2");
89  }
90 }
void dumpExceptions(const char *prefix)
void rethrow_exception(std::exception_ptr ep)