Scarab
v2.4.6
Project 8 C++ Utility Library
library
test
test_terminate.cc
Go to the documentation of this file.
1
/*
2
* test_terminate.cc
3
*
4
* Created on: May 23, 2017
5
* Author: N.S. Oblath
6
*/
7
8
#include "
terminate.hh
"
9
10
#include "
logger.hh
"
11
12
LOGGER
( slog,
"test_terminate"
);
13
14
namespace
scarab
15
{
16
int
throw_exception
()
17
{
18
// throw an unhandled runtime error
19
throw
std::runtime_error(
"RUNTIME ERROR!"
);
20
return
0;
21
}
22
23
int
foo2
()
24
{
25
throw_exception
();
26
return
0;
27
}
28
29
int
foo1
()
30
{
31
foo2
();
32
return
0;
33
}
34
}
35
36
int
main
(
int
,
char
** )
37
{
38
// Use for option 2 (signal handling)
39
//struct sigaction sigact;
40
41
//sigact.sa_sigaction = scarab::crit_err_hdlr;
42
//sigact.sa_flags = SA_RESTART | SA_SIGINFO;
43
44
// set the error handler
45
//if( sigaction(SIGABRT, &sigact, (struct sigaction *)NULL) != 0 )
46
//{
47
// LERROR( slog, "error setting handler for signal " << SIGABRT
48
// << " (" << strsignal(SIGABRT) << ")" );
49
// exit(EXIT_FAILURE);
50
//}
51
52
// cause the exception to be thrown
53
scarab::foo1
();
54
55
exit(EXIT_SUCCESS);
56
}
terminate.hh
scarab::throw_exception
int throw_exception()
Definition:
test_terminate.cc:16
main
int main(int, char **)
Definition:
test_terminate.cc:36
LOGGER
LOGGER(slog, "test_terminate")
scarab
Definition:
authentication.cc:18
logger.hh
Contains the logger class and macros, based on Kasper's KLogger class.
scarab::foo2
int foo2()
Definition:
test_terminate.cc:23
scarab::foo1
int foo1()
Definition:
test_terminate.cc:29
Generated by
1.8.13