From 9a0b88bf7777c153dc46ace22db74ef24d51583a Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 29 Apr 2008 12:55:25 +0000 Subject: update release date to actual date git-svn-id: svn+q:///qpdf/trunk@599 71b93d88-0707-0410-a8cf-f5a4172ac649 --- libtests/qexc.cc | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 libtests/qexc.cc (limited to 'libtests/qexc.cc') diff --git a/libtests/qexc.cc b/libtests/qexc.cc new file mode 100644 index 00000000..db12d39c --- /dev/null +++ b/libtests/qexc.cc @@ -0,0 +1,65 @@ + +#include +#include +#include + +void do_terminate() +{ + try + { + throw; + } + catch (std::exception& e) + { + std::cerr << "uncaught exception: " << e.what() << std::endl; + exit(3); + } + exit(4); +} + +void f(int n) +{ + switch (n) + { + case 0: + throw QEXC::General("general exception"); + break; + + case 1: + throw QEXC::Internal("internal error"); + break; + + case 2: + throw QEXC::System("doing something", EINVAL); + break; + + case 3: + { + int a = -1; + new char[a]; + } + break; + } +} + +int main(int argc, char* argv[]) +{ + std::set_terminate(do_terminate); + if (argc != 2) + { + std::cerr << "usage: qexc n" << std::endl; + exit(2); + } + + try + { + f(atoi(argv[1])); + } + catch (QEXC::General& e) + { + std::cerr << "exception: " << e.unparse() << std::endl; + std::cerr << "what: " << e.what() << std::endl; + exit(2); + } + return 0; +} -- cgit v1.2.3-54-g00ecf