1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 /*
21  * XSEC
22  *
23  * XSECError := General include file for handling errors
24  *
25  * Author(s): Berin Lautenbach
26  *
27  * $Id: XSECError.hpp 1807011 2017-09-01 22:51:20Z scantor $
28  *
29  */
30 
31 #include <xsec/framework/XSECDefs.hpp>
32 #include <xsec/framework/XSECException.hpp>
33 #include <xsec/enc/XSECCryptoException.hpp>
34 #include <new>
35 
36 /**
37  * @defgroup pubsig Main Signature API
38  * This section describes the main classes and interfaces necessary for
39  * programming with the XML-Security-C library.
40  * @{
41  */
42 
43 /**
44  * \brief Error strings
45  *
46  * An array that can be used to obtain an error string associated with
47  * an exception number.
48  */
49 
50 extern const char * XSECExceptionStrings [];
51 
52 /** @} */
53 
54 #if defined (_WIN32) && defined (_DEBUG) && defined (_XSEC_DO_MEMDEBUG_OLD)
55 
56 #	define XSECnew( a, b ) \
57 	try {\
58 		if (( a = DEBUG_NEW b ) == NULL) { \
59 			throw XSECException (XSECException::MemoryAllocationFail); \
60 		}\
61 	} \
62 	catch (const XSECCryptoException &e) \
63 	{\
64 		throw XSECException (XSECException::InternalError, e.getMsg()); \
65 	} \
66 	catch (const std::bad_alloc&) { \
67 		throw XSECException (XSECException::MemoryAllocationFail); \
68 	}
69 
70 #else
71 
72 #	define XSECnew(a, b) \
73 	try {\
74 		if ((a = new b) == NULL) { \
75 			throw XSECException (XSECException::MemoryAllocationFail); \
76 		} \
77 	} \
78 	catch (const XSECCryptoException &e) \
79 	{\
80 		throw XSECException (XSECException::InternalError, e.getMsg()); \
81 	} \
82 	catch (const std::bad_alloc&) { \
83 		throw XSECException (XSECException::MemoryAllocationFail); \
84 	}
85 
86 #endif
87