CARMA C++
ExceptionUtils.h
1 #ifndef CARMA_UTIL_EXCEPTION_UTILS_H
2 #define CARMA_UTIL_EXCEPTION_UTILS_H
3 
4 
5 #include <string>
6 
7 #include <log4cpp/Priority.hh>
8 #include <log4cpp/Category.hh>
9 
10 namespace carma {
11 namespace util {
12 
13 
14 class Logger;
15 
16 
17 ::std::string getStringForCaught( );
18 
19 
20 void logCaught( log4cpp::Category & logger,
21  log4cpp::Priority::PriorityLevel priority );
22 void logCaught( log4cpp::Category & logger,
23  log4cpp::Priority::PriorityLevel priority,
24  const ::std::string & preface );
25 
26 void logCaught( log4cpp::Priority::PriorityLevel priority );
27 void logCaught( log4cpp::Priority::PriorityLevel priority,
28  const ::std::string & preface );
29 
30 void logCaughtAsError( log4cpp::Category & logger );
31 void logCaughtAsError( log4cpp::Category & logger,
32  const ::std::string & preface );
33 
34 void logCaughtAsError( );
35 void logCaughtAsError( const ::std::string & preface );
36 
37 void traceCaught( int traceLevel );
38 
39 
40 void rethrowCaughtAsUser( );
41 
42 void logCaughtAndRethrowAsUser( log4cpp::Category & logger,
43  log4cpp::Priority::PriorityLevel priority );
44 void logCaughtAndRethrowAsUser( log4cpp::Category & logger,
45  log4cpp::Priority::PriorityLevel priority,
46  const ::std::string & preface );
47 void logCaughtAndRethrowAsUser( log4cpp::Category & logger,
48  log4cpp::Priority::PriorityLevel priority,
49  const char * preface );
50 
51 void logCaughtAndRethrowAsUser( log4cpp::Priority::PriorityLevel priority );
52 void logCaughtAndRethrowAsUser( log4cpp::Priority::PriorityLevel priority,
53  const ::std::string & preface );
54 void logCaughtAndRethrowAsUser( log4cpp::Priority::PriorityLevel priority,
55  const char * preface );
56 
57 void logCaughtAsErrorAndRethrowAsUser( log4cpp::Category & logger );
58 void logCaughtAsErrorAndRethrowAsUser( log4cpp::Category & logger,
59  const ::std::string & preface );
60 void logCaughtAsErrorAndRethrowAsUser( log4cpp::Category & logger,
61  const char * preface );
62 
63 void logCaughtAsErrorAndRethrowAsUser( );
64 void logCaughtAsErrorAndRethrowAsUser( const ::std::string & preface );
65 void logCaughtAsErrorAndRethrowAsUser( const char * preface );
66 
67 void traceCaughtAndRethrowAsUser( int traceLevel );
68 
69 
70 void terminateHandler( );
71 
72 void unexpectedHandler( );
73 
74 
75 bool caughtBacktraceCaptured( );
76 
77 
78 ::std::string getCaughtBacktraceAsString( );
79 
80 ::std::string getCaughtBacktraceAsString( const ::std::string & linePrefix,
81  const ::std::string & lineSuffix );
82 
83 ::std::string getCaughtBacktraceAsString( const char * linePrefix,
84  const char * lineSuffix );
85 
86 
87 void logCaughtBacktraceAsError( log4cpp::Category & logger );
88 
89 void logCaughtBacktraceAsError( log4cpp::Category & logger,
90  const ::std::string & linePrefix );
91 
92 void logCaughtBacktraceAsError( log4cpp::Category & logger,
93  const char * linePrefix );
94 
95 void logCaughtBacktraceAsErrorIfPossible( );
96 
97 void logCaughtBacktraceAsErrorIfPossible( const ::std::string & linePrefix );
98 
99 void logCaughtBacktraceAsErrorIfPossible( const char * linePrefix );
100 
101 
102 // old (deprecated) names for some of these
103 
104 
105 inline void
106 logAndRethrowCaughtExceptionAsUserException(
107  log4cpp::Category & logger,
108  const log4cpp::Priority::PriorityLevel priority )
109 {
110  logCaughtAndRethrowAsUser( logger, priority );
111 }
112 
113 
114 inline void
115 logAndRethrowCaughtExceptionAsUserException(
116  const log4cpp::Priority::PriorityLevel priority )
117 {
118  logCaughtAndRethrowAsUser( priority );
119 }
120 
121 
122 } // namespace carma::util
123 } // namespace carma
124 
125 
126 #endif