OpenSSL  1.0.1c
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
ErrorHandling.hpp
Go to the documentation of this file.
1 #ifdef __cplusplus
2 extern "C" {
3 #endif
4 
5 #ifndef kGenericError
6  #define kGenericError -1
7 #endif
8 
9 extern char *gErrorMessage;
10 
11 
12 void SetErrorMessage(const char *theErrorMessage);
13 void SetErrorMessageAndAppendLongInt(const char *theErrorMessage,const long theLongInt);
14 void SetErrorMessageAndCStrAndLongInt(const char *theErrorMessage,const char * theCStr,const long theLongInt);
15 void SetErrorMessageAndCStr(const char *theErrorMessage,const char * theCStr);
16 void AppendCStrToErrorMessage(const char *theErrorMessage);
17 void AppendLongIntToErrorMessage(const long theLongInt);
18 
19 
20 char *GetErrorMessage(void);
21 OSErr GetErrorMessageInNewHandle(Handle *inoutHandle);
22 OSErr GetErrorMessageInExistingHandle(Handle inoutHandle);
23 OSErr AppendErrorMessageToHandle(Handle inoutHandle);
24 
25 
26 #ifdef __EXCEPTIONS_ENABLED__
27  void ThrowErrorMessageException(void);
28 #endif
29 
30 
31 
32 // A bunch of evil macros that would be unnecessary if I were always using C++ !
33 
34 #define SetErrorMessageAndBailIfNil(theArg,theMessage) \
35 { \
36  if (theArg == nil) \
37  { \
38  SetErrorMessage(theMessage); \
39  errCode = kGenericError; \
40  goto EXITPOINT; \
41  } \
42 }
43 
44 
45 #define SetErrorMessageAndBail(theMessage) \
46 { \
47  SetErrorMessage(theMessage); \
48  errCode = kGenericError; \
49  goto EXITPOINT; \
50 }
51 
52 
53 #define SetErrorMessageAndLongIntAndBail(theMessage,theLongInt) \
54 { \
55  SetErrorMessageAndAppendLongInt(theMessage,theLongInt); \
56  errCode = kGenericError; \
57  goto EXITPOINT; \
58 }
59 
60 
61 #define SetErrorMessageAndLongIntAndBailIfError(theErrCode,theMessage,theLongInt) \
62 { \
63  if (theErrCode != noErr) \
64  { \
65  SetErrorMessageAndAppendLongInt(theMessage,theLongInt); \
66  errCode = theErrCode; \
67  goto EXITPOINT; \
68  } \
69 }
70 
71 
72 #define SetErrorMessageCStrLongIntAndBailIfError(theErrCode,theMessage,theCStr,theLongInt) \
73 { \
74  if (theErrCode != noErr) \
75  { \
76  SetErrorMessageAndCStrAndLongInt(theMessage,theCStr,theLongInt); \
77  errCode = theErrCode; \
78  goto EXITPOINT; \
79  } \
80 }
81 
82 
83 #define SetErrorMessageAndCStrAndBail(theMessage,theCStr) \
84 { \
85  SetErrorMessageAndCStr(theMessage,theCStr); \
86  errCode = kGenericError; \
87  goto EXITPOINT; \
88 }
89 
90 
91 #define SetErrorMessageAndBailIfError(theErrCode,theMessage) \
92 { \
93  if (theErrCode != noErr) \
94  { \
95  SetErrorMessage(theMessage); \
96  errCode = theErrCode; \
97  goto EXITPOINT; \
98  } \
99 }
100 
101 
102 #define SetErrorMessageAndLongIntAndBailIfNil(theArg,theMessage,theLongInt) \
103 { \
104  if (theArg == nil) \
105  { \
106  SetErrorMessageAndAppendLongInt(theMessage,theLongInt); \
107  errCode = kGenericError; \
108  goto EXITPOINT; \
109  } \
110 }
111 
112 
113 #define BailIfError(theErrCode) \
114 { \
115  if ((theErrCode) != noErr) \
116  { \
117  goto EXITPOINT; \
118  } \
119 }
120 
121 
122 #define SetErrCodeAndBail(theErrCode) \
123 { \
124  errCode = theErrCode; \
125  \
126  goto EXITPOINT; \
127 }
128 
129 
130 #define SetErrorCodeAndMessageAndBail(theErrCode,theMessage) \
131 { \
132  SetErrorMessage(theMessage); \
133  errCode = theErrCode; \
134  goto EXITPOINT; \
135 }
136 
137 
138 #define BailNow() \
139 { \
140  errCode = kGenericError; \
141  goto EXITPOINT; \
142 }
143 
144 
145 #ifdef __cplusplus
146 }
147 #endif