qca
exceptn.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 1999-2007 The Botan Project. All rights reserved. 00003 00004 Redistribution and use in source and binary forms, for any use, with or without 00005 modification, is permitted provided that the following conditions are met: 00006 00007 1. Redistributions of source code must retain the above copyright notice, this 00008 list of conditions, and the following disclaimer. 00009 00010 2. Redistributions in binary form must reproduce the above copyright notice, 00011 this list of conditions, and the following disclaimer in the documentation 00012 and/or other materials provided with the distribution. 00013 00014 THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED 00015 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00016 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. 00017 00018 IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT, 00019 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00020 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00021 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00022 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00023 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00024 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 */ 00026 // LICENSEHEADER_END 00027 namespace QCA { // WRAPNS_LINE 00028 /************************************************* 00029 * Exceptions Header File * 00030 * (C) 1999-2007 The Botan Project * 00031 *************************************************/ 00032 00033 #ifndef BOTAN_EXCEPTION_H__ 00034 #define BOTAN_EXCEPTION_H__ 00035 00036 } // WRAPNS_LINE 00037 #include <botan/types.h> 00038 namespace QCA { // WRAPNS_LINE 00039 } // WRAPNS_LINE 00040 #include <exception> 00041 namespace QCA { // WRAPNS_LINE 00042 } // WRAPNS_LINE 00043 #include <string> 00044 namespace QCA { // WRAPNS_LINE 00045 00046 namespace Botan { 00047 00048 /************************************************* 00049 * Exception Base Class * 00050 *************************************************/ 00051 class Exception : public std::exception 00052 { 00053 public: 00054 const char* what() const throw() { return msg.c_str(); } 00055 Exception(const std::string& m = "Unknown error") { set_msg(m); } 00056 virtual ~Exception() throw() {} 00057 protected: 00058 void set_msg(const std::string& m) { msg = "Botan: " + m; } 00059 private: 00060 std::string msg; 00061 }; 00062 00063 /************************************************* 00064 * Invalid_Argument Exception * 00065 *************************************************/ 00066 struct Invalid_Argument : public Exception 00067 { 00068 Invalid_Argument(const std::string& err = "") : Exception(err) {} 00069 }; 00070 00071 /************************************************* 00072 * Invalid_Key_Length Exception * 00073 *************************************************/ 00074 struct Invalid_Key_Length : public Invalid_Argument 00075 { 00076 Invalid_Key_Length(const std::string&, u32bit); 00077 }; 00078 00079 /************************************************* 00080 * Invalid_Block_Size Exception * 00081 *************************************************/ 00082 struct Invalid_Block_Size : public Invalid_Argument 00083 { 00084 Invalid_Block_Size(const std::string&, const std::string&); 00085 }; 00086 00087 /************************************************* 00088 * Invalid_IV_Length Exception * 00089 *************************************************/ 00090 struct Invalid_IV_Length : public Invalid_Argument 00091 { 00092 Invalid_IV_Length(const std::string&, u32bit); 00093 }; 00094 00095 /************************************************* 00096 * Invalid_Message_Number Exception * 00097 *************************************************/ 00098 struct Invalid_Message_Number : public Invalid_Argument 00099 { 00100 Invalid_Message_Number(const std::string&, u32bit); 00101 }; 00102 00103 /************************************************* 00104 * Invalid_State Exception * 00105 *************************************************/ 00106 struct Invalid_State : public Exception 00107 { 00108 Invalid_State(const std::string& err) : Exception(err) {} 00109 }; 00110 00111 /************************************************* 00112 * PRNG_Unseeded Exception * 00113 *************************************************/ 00114 struct PRNG_Unseeded : public Invalid_State 00115 { 00116 PRNG_Unseeded(const std::string& algo) : 00117 Invalid_State("PRNG not seeded: " + algo) {} 00118 }; 00119 00120 /************************************************* 00121 * Policy_Violation Exception * 00122 *************************************************/ 00123 struct Policy_Violation : public Invalid_State 00124 { 00125 Policy_Violation(const std::string& err) : 00126 Invalid_State("Policy violation: " + err) {} 00127 }; 00128 00129 /************************************************* 00130 * Lookup_Error Exception * 00131 *************************************************/ 00132 struct Lookup_Error : public Exception 00133 { 00134 Lookup_Error(const std::string& err) : Exception(err) {} 00135 }; 00136 00137 /************************************************* 00138 * Algorithm_Not_Found Exception * 00139 *************************************************/ 00140 struct Algorithm_Not_Found : public Exception 00141 { 00142 Algorithm_Not_Found(const std::string&); 00143 }; 00144 00145 /************************************************* 00146 * Format_Error Exception * 00147 *************************************************/ 00148 struct Format_Error : public Exception 00149 { 00150 Format_Error(const std::string& err = "") : Exception(err) {} 00151 }; 00152 00153 /************************************************* 00154 * Invalid_Algorithm_Name Exception * 00155 *************************************************/ 00156 struct Invalid_Algorithm_Name : public Format_Error 00157 { 00158 Invalid_Algorithm_Name(const std::string&); 00159 }; 00160 00161 /************************************************* 00162 * Encoding_Error Exception * 00163 *************************************************/ 00164 struct Encoding_Error : public Format_Error 00165 { 00166 Encoding_Error(const std::string& name) : 00167 Format_Error("Encoding error: " + name) {} 00168 }; 00169 00170 /************************************************* 00171 * Decoding_Error Exception * 00172 *************************************************/ 00173 struct Decoding_Error : public Format_Error 00174 { 00175 Decoding_Error(const std::string& name) : 00176 Format_Error("Decoding error: " + name) {} 00177 }; 00178 00179 /************************************************* 00180 * Invalid_OID Exception * 00181 *************************************************/ 00182 struct Invalid_OID : public Decoding_Error 00183 { 00184 Invalid_OID(const std::string& oid) : 00185 Decoding_Error("Invalid ASN.1 OID: " + oid) {} 00186 }; 00187 00188 /************************************************* 00189 * Stream_IO_Error Exception * 00190 *************************************************/ 00191 struct Stream_IO_Error : public Exception 00192 { 00193 Stream_IO_Error(const std::string& err) : 00194 Exception("I/O error: " + err) {} 00195 }; 00196 00197 /************************************************* 00198 * Configuration Error Exception * 00199 *************************************************/ 00200 struct Config_Error : public Format_Error 00201 { 00202 Config_Error(const std::string& err) : 00203 Format_Error("Config error: " + err) {} 00204 Config_Error(const std::string&, u32bit); 00205 }; 00206 00207 /************************************************* 00208 * Integrity Failure Exception * 00209 *************************************************/ 00210 struct Integrity_Failure : public Exception 00211 { 00212 Integrity_Failure(const std::string& err) : 00213 Exception("Integrity failure: " + err) {} 00214 }; 00215 00216 /************************************************* 00217 * Internal_Error Exception * 00218 *************************************************/ 00219 struct Internal_Error : public Exception 00220 { 00221 Internal_Error(const std::string& err) : 00222 Exception("Internal error: " + err) {} 00223 }; 00224 00225 /************************************************* 00226 * Self Test Failure Exception * 00227 *************************************************/ 00228 struct Self_Test_Failure : public Internal_Error 00229 { 00230 Self_Test_Failure(const std::string& err) : 00231 Internal_Error("Self test failed: " + err) {} 00232 }; 00233 00234 /************************************************* 00235 * Memory Allocation Exception * 00236 *************************************************/ 00237 struct Memory_Exhaustion : public Exception 00238 { 00239 Memory_Exhaustion() : 00240 Exception("Ran out of memory, allocation failed") {} 00241 }; 00242 00243 } 00244 00245 #endif 00246 } // WRAPNS_LINE
KDE 4.4 API Reference