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; } |
I2luY2x1ZGUgPHN0ZGV4Y2VwdD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNzdGRpbz4KCmNsYXNzIG15X2V4Y2VwdGlvbjogcHVibGljIHN0ZDo6bG9naWNfZXJyb3IKewpwdWJsaWM6CiAgICBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gY2FsbHN0YWNrOwoKICAgIG15X2V4Y2VwdGlvbihjb25zdCBzdGQ6OnN0cmluZyYgcykgOiBzdGQ6OmxvZ2ljX2Vycm9yKHMpe30KICAgIHZpcnR1YWwgfm15X2V4Y2VwdGlvbigpIHRocm93KCkge30KfTsKCmludCBtYWluKCkKewogIHRyeQogIHsKICAgIHRyeQogICAgewogICAgICAgIHRocm93IG15X2V4Y2VwdGlvbigiMTIzNDUiKTsKICAgIH0KICAgIGNhdGNoIChteV9leGNlcHRpb24gJiBlKQogICAgewogICAgICAgIGUuY2FsbHN0YWNrLnB1c2hfYmFjaygiTXlGdW5jIik7CiAgICAgICAgdGhyb3c7CiAgICB9CiAgfQogIGNhdGNoIChjb25zdCBteV9leGNlcHRpb24mIGUpCiAgewogICAgZm9yIChzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz46OmNvbnN0X2l0ZXJhdG9yIGl0ID0gZS5jYWxsc3RhY2suYmVnaW4oKTsgaXQgIT0gZS5jYWxsc3RhY2suZW5kKCk7ICsrIGl0KQogICAgICBwcmludGYoIiVzXG4iLCBpdC0+Y19zdHIoKSk7CiAgICB0aHJvdzsKICB9CiAgcmV0dXJuIDA7Cn0K
-
upload with new input
-
result: Runtime error time: 0s memory: 2860 kB signal: 6
MyFunc
terminate called after throwing an instance of 'my_exception' what(): 12345


