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  * XSECException:= How we throw exceptions in XSEC
24  *
25  * Author(s): Berin Lautenbach
26  *
27  * $ID$
28  *
29  * $LOG$
30  *
31  */
32 
33 #include <xsec/framework/XSECError.hpp>
34 
35 #include "../utils/XSECDOMUtils.hpp"
36 
XSECException(XSECExceptionType eNum,const XMLCh * inMsg)37 XSECException::XSECException(XSECExceptionType eNum, const XMLCh * inMsg) {
38 
39 	if (eNum > UnknownError)
40 		type = UnknownError;
41 	else
42 		type = eNum;
43 
44 	if (inMsg != NULL) {
45 		msg = XMLString::replicate(inMsg);
46 	}
47 	else {
48 		msg = XMLString::transcode(XSECExceptionStrings[type]);
49 	}
50 
51 }
52 
XSECException(XSECExceptionType eNum,const char * inMsg)53 XSECException::XSECException(XSECExceptionType eNum, const char * inMsg) {
54 
55 	if (eNum > UnknownError)
56 		type = UnknownError;
57 	else
58 		type = eNum;
59 
60 	if (inMsg != NULL) {
61 		msg = XMLString::transcode(inMsg);
62 	}
63 	else {
64 		msg = XMLString::transcode(XSECExceptionStrings[type]);
65 	}
66 
67 }
68 
XSECException(const XSECException & toCopy)69 XSECException::XSECException(const XSECException &toCopy) {
70 
71 	// Copy Constructor
72 
73 	type = toCopy.type;
74 	if (toCopy.msg == NULL)
75 		msg = NULL;
76 	else {
77 		msg = XMLString::replicate(toCopy.msg);
78 	}
79 }
80 
~XSECException()81 XSECException::~XSECException() {
82 
83 	if (msg != NULL)
84 		XSEC_RELEASE_XMLCH(msg);
85 
86 }
87 
getMsg(void) const88 const XMLCh * XSECException::getMsg(void) const {
89 
90 	return msg;
91 
92 }
93 
getType(void) const94 XSECException::XSECExceptionType XSECException::getType(void) const {
95 
96 	return type;
97 
98 }
99