language: C++ 4.7.2 (gcc-4.7.2)
date: 525 days 13 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdexcept>
#include <vector>
#include <string>
#include <cstdio>
 
class my_exception: public std::logic_error
{
public:
    std::vector<std::string> callstack;
 
    my_exception(const std::string& s) : std::logic_error(s){}
    virtual ~my_exception() throw() {}
};
 
int main()
{
  try
  {
    try
    {
        throw my_exception("12345");
    }
    catch (my_exception & e)
    {
        e.callstack.push_back("MyFunc");
        throw;
    }
  }
  catch (const my_exception& e)
  {
    for (std::vector<std::string>::const_iterator it = e.callstack.begin(); it != e.callstack.end(); ++ it)
      printf("%s\n", it->c_str());
    throw;
  }
  return 0;
}