Botan: src/utils/exceptn.h Source File

Botan 1.10.17

exceptn.h
Go to the documentation of this file.
1 /*
2 * Exceptions
3 * (C) 1999-2009 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_EXCEPTION_H__
9 #define BOTAN_EXCEPTION_H__
10
11 #include <botan/types.h>
12 #include <botan/parsing.h>
13 #include <exception>
14 #include <stdexcept>
15 #include <string>
16
17 namespace Botan {
18
19 typedef std::runtime_error Exception;
20 typedef std::invalid_argument Invalid_Argument;
21
22 /**
23 * Invalid_State Exception
24 */
25 struct BOTAN_DLL Invalid_State : public Exception
26 {
27 Invalid_State(const std::string& err) :
28 Exception(err)
29 {}
30 };
31
32 /**
33 * Lookup_Error Exception
34 */
35 struct BOTAN_DLL Lookup_Error : public Exception
36 {
37 Lookup_Error(const std::string& err) :
38 Exception(err)
39 {}
40 };
41
42 /**
43 * Internal_Error Exception
44 */
45 struct BOTAN_DLL Internal_Error : public Exception
46 {
47 Internal_Error(const std::string& err) :
48 Exception("Internal error: " + err)
49 {}
50 };
51
52 /**
53 * Invalid_Key_Length Exception
54 */
55 struct BOTAN_DLL Invalid_Key_Length : public Invalid_Argument
56 {
57 Invalid_Key_Length(const std::string& name, size_t length) :
58 Invalid_Argument(name + " cannot accept a key of length " +
59 to_string(length))
60 {}
61 };
62
63 /**
64 * Invalid_Block_Size Exception
65 */
66 struct BOTAN_DLL Invalid_Block_Size : public Invalid_Argument
67 {
68 Invalid_Block_Size(const std::string& mode,
69 const std::string& pad) :
70 Invalid_Argument("Padding method " + pad +
71 " cannot be used with " + mode)
72 {}
73 };
74
75 /**
76 * Invalid_IV_Length Exception
77 */
78 struct BOTAN_DLL Invalid_IV_Length : public Invalid_Argument
79 {
80 Invalid_IV_Length(const std::string& mode, size_t bad_len) :
81 Invalid_Argument("IV length " + to_string(bad_len) +
82 " is invalid for " + mode)
83 {}
84 };
85
86 /**
87 * PRNG_Unseeded Exception
88 */
89 struct BOTAN_DLL PRNG_Unseeded : public Invalid_State
90 {
91 PRNG_Unseeded(const std::string& algo) :
92 Invalid_State("PRNG not seeded: " + algo)
93 {}
94 };
95
96 /**
97 * Policy_Violation Exception
98 */
99 struct BOTAN_DLL Policy_Violation : public Invalid_State
100 {
101 Policy_Violation(const std::string& err) :
102 Invalid_State("Policy violation: " + err)
103 {}
104 };
105
106 /**
107 * Algorithm_Not_Found Exception
108 */
109 struct BOTAN_DLL Algorithm_Not_Found : public Lookup_Error
110 {
111 Algorithm_Not_Found(const std::string& name) :
112 Lookup_Error("Could not find any algorithm named \"" + name + "\"")
113 {}
114 };
115
116 /**
117 * Invalid_Algorithm_Name Exception
118 */
119 struct BOTAN_DLL Invalid_Algorithm_Name : public Invalid_Argument
120 {
121 Invalid_Algorithm_Name(const std::string& name):
122 Invalid_Argument("Invalid algorithm name: " + name)
123 {}
124 };
125
126 /**
127 * Encoding_Error Exception
128 */
129 struct BOTAN_DLL Encoding_Error : public Invalid_Argument
130 {
131 Encoding_Error(const std::string& name) :
132 Invalid_Argument("Encoding error: " + name) {}
133 };
134
135 /**
136 * Decoding_Error Exception
137 */
138 struct BOTAN_DLL Decoding_Error : public Invalid_Argument
139 {
140 Decoding_Error(const std::string& name) :
141 Invalid_Argument("Decoding error: " + name) {}
142 };
143
144 /**
145 * Integrity_Failure Exception
146 */
147 struct BOTAN_DLL Integrity_Failure : public Exception
148 {
149 Integrity_Failure(const std::string& msg) :
150 Exception("Integrity failure: " + msg) {}
151 };
152
153 /**
154 * Invalid_OID Exception
155 */
156 struct BOTAN_DLL Invalid_OID : public Decoding_Error
157 {
158 Invalid_OID(const std::string& oid) :
159 Decoding_Error("Invalid ASN.1 OID: " + oid) {}
160 };
161
162 /**
163 * Stream_IO_Error Exception
164 */
165 struct BOTAN_DLL Stream_IO_Error : public Exception
166 {
167 Stream_IO_Error(const std::string& err) :
168 Exception("I/O error: " + err)
169 {}
170 };
171
172 /**
173 * Self Test Failure Exception
174 */
175 struct BOTAN_DLL Self_Test_Failure : public Internal_Error
176 {
177 Self_Test_Failure(const std::string& err) :
178 Internal_Error("Self test failed: " + err)
179 {}
180 };
181
182 /**
183 * Memory Allocation Exception
184 */
185 struct BOTAN_DLL Memory_Exhaustion : public std::bad_alloc
186 {
187 const char* what() const throw()
188 { return "Ran out of memory, allocation failed"; }
189 };
190
191 }
192
193 #endif
Botan::Stream_IO_Error
Definition: exceptn.h:165
Botan::Invalid_IV_Length::Invalid_IV_Length
Invalid_IV_Length(const std::string &mode, size_t bad_len)
Definition: exceptn.h:80
Botan::Invalid_Key_Length
Definition: exceptn.h:55
Botan::Invalid_Block_Size::Invalid_Block_Size
Invalid_Block_Size(const std::string &mode, const std::string &pad)
Definition: exceptn.h:68
Botan::Memory_Exhaustion
Definition: exceptn.h:185
Botan::Invalid_Key_Length::Invalid_Key_Length
Invalid_Key_Length(const std::string &name, size_t length)
Definition: exceptn.h:57
Botan::Algorithm_Not_Found::Algorithm_Not_Found
Algorithm_Not_Found(const std::string &name)
Definition: exceptn.h:111
Botan::PRNG_Unseeded::PRNG_Unseeded
PRNG_Unseeded(const std::string &algo)
Definition: exceptn.h:91
Botan::Integrity_Failure
Definition: exceptn.h:147
Botan::Stream_IO_Error::Stream_IO_Error
Stream_IO_Error(const std::string &err)
Definition: exceptn.h:167
Botan::Internal_Error
Definition: exceptn.h:45
Botan::Invalid_State
Definition: exceptn.h:25
Botan::Invalid_Argument
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::Invalid_IV_Length
Definition: exceptn.h:78
Botan::Internal_Error::Internal_Error
Internal_Error(const std::string &err)
Definition: exceptn.h:47
Botan::Integrity_Failure::Integrity_Failure
Integrity_Failure(const std::string &msg)
Definition: exceptn.h:149
Botan::Decoding_Error::Decoding_Error
Decoding_Error(const std::string &name)
Definition: exceptn.h:140
Botan::Policy_Violation
Definition: exceptn.h:99
Botan::Invalid_Algorithm_Name::Invalid_Algorithm_Name
Invalid_Algorithm_Name(const std::string &name)
Definition: exceptn.h:121
Botan::Self_Test_Failure::Self_Test_Failure
Self_Test_Failure(const std::string &err)
Definition: exceptn.h:177
Botan::Lookup_Error
Definition: exceptn.h:35
Botan::Decoding_Error
Definition: exceptn.h:138
Botan::Exception
std::runtime_error Exception
Definition: exceptn.h:19
Botan
Definition: algo_base.h:14
Botan::Invalid_State::Invalid_State
Invalid_State(const std::string &err)
Definition: exceptn.h:27
Botan::Invalid_Algorithm_Name
Definition: exceptn.h:119
Botan::Self_Test_Failure
Definition: exceptn.h:175
Botan::to_string
std::string to_string(u64bit n, size_t min_len)
Definition: parsing.cpp:42
Botan::Lookup_Error::Lookup_Error
Lookup_Error(const std::string &err)
Definition: exceptn.h:37
Botan::Algorithm_Not_Found
Definition: exceptn.h:109
Botan::Memory_Exhaustion::what
const char * what() const
Definition: exceptn.h:187
Botan::Policy_Violation::Policy_Violation
Policy_Violation(const std::string &err)
Definition: exceptn.h:101
Botan::Encoding_Error::Encoding_Error
Encoding_Error(const std::string &name)
Definition: exceptn.h:131
Botan::Encoding_Error
Definition: exceptn.h:129
Botan::Invalid_Block_Size
Definition: exceptn.h:66
Botan::PRNG_Unseeded
Definition: exceptn.h:89
Botan::Invalid_OID
Definition: exceptn.h:156
oid
OID oid
Definition: x509_ext.cpp:446
Botan::Invalid_OID::Invalid_OID
Invalid_OID(const std::string &oid)
Definition: exceptn.h:158