exception stack trace

This commit is contained in:
Matej Sekoranja
2010-10-25 00:16:43 +02:00
parent ef709eb6b9
commit d97e9c12ed
3 changed files with 169 additions and 9 deletions

View File

@@ -13,6 +13,29 @@
using namespace epics::pvData;
struct Unroller
{
template <int N>
void unroll(double d) {
unroll<N-1>(d);
}
};
template<>
void Unroller::unroll<0>(double d) {
THROW_BASE_EXCEPTION("the root cause");
}
void internalTestBaseException(int unused = 0)
{
try {
// NOTE: 5, 4, 3, 2, 1 calls will be optimized and not shown
Unroller().unroll<5>(42.0);
} catch (BaseException *be3) {
THROW_BASE_EXCEPTION_CAUSE("exception 1", be3);
}
}
void testBaseException() {
printf("testBaseException... ");
@@ -26,13 +49,9 @@ void testBaseException() {
try {
try {
try {
THROW_BASE_EXCEPTION("the root cause");
} catch (BaseException *be3) {
THROW_BASE_EXCEPTION_CAUSE("exception 1", be3);
}
internalTestBaseException();
} catch (BaseException *be2) {
THROW_BASE_EXCEPTION_CAUSE("excepton 2", be2);
THROW_BASE_EXCEPTION_CAUSE("exception 2", be2);
}
} catch (BaseException *be) {
std::string str;