1#include "../Exception.h" 2#include <stdio.h> 3 4class Bar 5{ 6 public: 7 void test() 8 { 9 throw muduo::Exception("oops"); 10 } 11}; 12 13void foo() 14{ 15 Bar b; 16 b.test(); 17} 18 19int main() 20{ 21 try 22 { 23 foo(); 24 } 25 catch (const muduo::Exception& ex) 26 { 27 printf("reason: %s\n", ex.what()); 28 printf("stack trace: %s\n", ex.stackTrace()); 29 } 30} 31