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