Scarab
v2.4.5
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
9
#include "
terminate.hh
"
10
11
#include "
logger.hh
"
12
13
LOGGER
( slog,
"test_terminate"
);
14
15
namespace
scarab
16
{
17
int
throw_exception
()
18
{
19
// throw an unhandled runtime error
20
throw
std::runtime_error(
"RUNTIME ERROR!"
);
21
return
0;
22
}
23
24
int
foo2
()
25
{
26
throw_exception
();
27
return
0;
28
}
29
30
int
foo1
()
31
{
32
foo2
();
33
return
0;
34
}
35
}
36
37
int
main
(
int
,
char
** )
38
{
39
// Use for option 2 (signal handling)
40
//struct sigaction sigact;
41
42
//sigact.sa_sigaction = scarab::crit_err_hdlr;
43
//sigact.sa_flags = SA_RESTART | SA_SIGINFO;
44
45
// set the error handler
46
//if( sigaction(SIGABRT, &sigact, (struct sigaction *)NULL) != 0 )
47
//{
48
// LERROR( slog, "error setting handler for signal " << SIGABRT
49
// << " (" << strsignal(SIGABRT) << ")" );
50
// exit(EXIT_FAILURE);
51
//}
52
53
// cause the exception to be thrown
54
scarab::foo1
();
55
56
exit(EXIT_SUCCESS);
57
}
terminate.hh
scarab::throw_exception
int throw_exception()
Definition:
test_terminate.cc:17
main
int main(int, char **)
Definition:
test_terminate.cc:37
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:24
scarab::foo1
int foo1()
Definition:
test_terminate.cc:30
Generated by
1.8.13