SGL
gexceptions.h
1 /*
2  * File: gexceptions.h
3  * -------------------
4  * This file contains a top-level exception handler to print exceptions thrown
5  * by student code on the console.
6  * It also contains some wizardry to try to retrieve a stack trace when the
7  * exception is thrown, though it is hard to consistently do this on all platforms.
8  *
9  * @author Marty Stepp
10  * @version 2021/04/03
11  * - removed dependencies
12  * - renamed to gexceptions
13  * @version 2018/09/25
14  * - add 'force' parameter to setTopLevelExceptionHandlerEnabled
15  * (helps it to work better with threads)
16  * - added doc comments for new documentation generation
17  * @version 2016/11/07
18  * - added cleanupFunctionNameForStackTrace
19  * @version 2016/10/30
20  * - moved recursion functions to recursion.h/cpp
21  * @version 2014/11/12
22  * - made printStackTrace function publicly available
23  * - added top-level signal handler (for null-pointer derefs etc.)
24  * @since 2014/11/05
25  */
26 
27 
28 #ifndef _exceptions_h
29 #define _exceptions_h
30 
31 #include <string>
32 
33 namespace gexceptions {
34 
39 string& getProgramName();
40 
45 
50 void setProgramName(char* programName);
51 
55 void setTopLevelExceptionHandlerEnabled(bool enabled);
56 
61 void interruptIfDebug();
62 
63 } // namespace gexceptions
64 
65 #endif // _gexceptions_h
void setProgramName(char *programName)
Called by C++ lib&#39;s main wrapper so that the stack trace knows the program&#39;s name.
Definition: gexceptions.cpp:150
bool getTopLevelExceptionHandlerEnabled()
Returns whether the top-level exception handler is enabled.
Definition: gexceptions.cpp:138
Definition: gexceptions.cpp:75
void interruptIfDebug()
If running under debugger, will interrupt program and return control to debugger (as if you pressed "...
Definition: gexceptions.cpp:124
void setTopLevelExceptionHandlerEnabled(bool enabled)
Sets whether the top-level exception handler is enabled.
Definition: gexceptions.cpp:176
string & getProgramName()
Called by C++ lib&#39;s main wrapper so that the stack trace knows the program&#39;s name.
Definition: gexceptions.cpp:146