Update copyright.
[shibboleth/cpp-opensaml.git] / saml / exceptions.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file saml/exceptions.h
19  * 
20  * Exception classes
21  */
22  
23 #ifndef __saml_exceptions_h__
24 #define __saml_exceptions_h__
25
26 #include <saml/base.h>
27 #include <xmltooling/exceptions.h>
28
29 namespace opensaml {
30     
31     namespace saml2md {
32         class SAML_API EntityDescriptor;
33         class SAML_API RoleDescriptor;
34     };
35     
36     DECL_XMLTOOLING_EXCEPTION(BindingException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::XMLToolingException,Exceptions in SAML binding processing);
37     DECL_XMLTOOLING_EXCEPTION(ProfileException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::ValidationException,Exceptions in SAML profile processing);
38     DECL_XMLTOOLING_EXCEPTION(FatalProfileException,SAML_EXCEPTIONAPI(SAML_API),opensaml,ProfileException,Fatal exceptions in SAML profile processing);
39     DECL_XMLTOOLING_EXCEPTION(RetryableProfileException,SAML_EXCEPTIONAPI(SAML_API),opensaml,ProfileException,Non-fatal exceptions in SAML profile processing);
40
41     /**
42      * Attaches metadata-derived information as exception properties and optionally
43      * rethrows the object. The following named properties are attached, when possible:
44      * 
45      *  <dl>
46      *  <dt>providerId</dt>     <dd>The unique ID of the entity</dd>
47      *  <dt>errorURL</dt>       <dd>The error support URL of a random role</dd>
48      *  <dt>contactName</dt>    <dd>A formatted support or technical contact name</dd>
49      *  <dt>contactEmail</dt>   <dd>A contact email address</dd>
50      *  </dl>
51      * 
52      * @param e         pointer to exception object
53      * @param entity    pointer to entity
54      * @param rethrow   true iff the exception should be rethrown
55      */
56     void SAML_API annotateException(
57         xmltooling::XMLToolingException* e, const saml2md::EntityDescriptor* entity, bool rethrow=true
58         );
59     
60     /**
61      * Attaches metadata-derived information as exception properties and optionally
62      * rethrows the object. The following named properties are attached, when possible:
63      * 
64      *  <dl>
65      *  <dt>providerId</dt>     <dd>The unique ID of the entity</dd>
66      *  <dt>errorURL</dt>       <dd>The error support URL of the role</dd>
67      *  <dt>contactName</dt>    <dd>A formatted support or technical contact name</dd>
68      *  <dt>contactEmail</dt>   <dd>A contact email address</dd>
69      *  </dl>
70      * 
71      * @param e         pointer to exception object
72      * @param entity    pointer to role
73      * @param rethrow   true iff the exception should be rethrown
74      */
75     void SAML_API annotateException(
76         xmltooling::XMLToolingException* e, const saml2md::RoleDescriptor* role, bool rethrow=true
77         );
78 };
79
80 #endif /* __saml_exceptions_h__ */