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/09
11  * - added sgl::exceptions namespace
12  * @version 2021/04/03
13  * - removed dependencies
14  * - renamed to gexceptions
15  * @version 2018/09/25
16  * - add 'force' parameter to setTopLevelExceptionHandlerEnabled
17  * (helps it to work better with threads)
18  * - added doc comments for new documentation generation
19  * @version 2016/11/07
20  * - added cleanupFunctionNameForStackTrace
21  * @version 2016/10/30
22  * - moved recursion functions to recursion.h/cpp
23  * @version 2014/11/12
24  * - made printStackTrace function publicly available
25  * - added top-level signal handler (for null-pointer derefs etc.)
26  * @since 2014/11/05
27  */
28 
29 
30 #ifndef _exceptions_h
31 #define _exceptions_h
32 
33 #include <string>
34 
35 namespace sgl {
36 namespace exceptions {
37 
42 string& getProgramName();
43 
48 
53 void setProgramName(char* programName);
54 
58 void setTopLevelExceptionHandlerEnabled(bool enabled);
59 
64 void interruptIfDebug();
65 
66 
67 } // namespace exceptions
68 } // namespace sgl
69 
70 #endif // _gexceptions_h
Definition: console.h:45
void interruptIfDebug()
If running under debugger, will interrupt program and return control to debugger (as if you pressed "...
Definition: gexceptions.cpp:127
void setTopLevelExceptionHandlerEnabled(bool enabled)
Sets whether the top-level exception handler is enabled.
Definition: gexceptions.cpp:179
bool getTopLevelExceptionHandlerEnabled()
Returns whether the top-level exception handler is enabled.
Definition: gexceptions.cpp:141
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:153
string & getProgramName()
Called by C++ lib&#39;s main wrapper so that the stack trace knows the program&#39;s name.
Definition: gexceptions.cpp:149