Botan  2.7.0
Crypto and TLS for C++11
exceptn.h
Go to the documentation of this file.
1 /*
2 * Exceptions
3 * (C) 1999-2009 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_EXCEPTION_H_
9 #define BOTAN_EXCEPTION_H_
10 
11 #include <botan/types.h>
12 #include <exception>
13 #include <string>
14 
15 namespace Botan {
16 
17 /**
18 * Base class for all exceptions thrown by the library
19 */
20 class BOTAN_PUBLIC_API(2,0) Exception : public std::exception
21  {
22  public:
23  Exception(const char* prefix, const std::string& msg);
24  explicit Exception(const std::string& msg);
25  const char* what() const BOTAN_NOEXCEPT override { return m_msg.c_str(); }
26  private:
27  std::string m_msg;
28  };
29 
30 /**
31 * An invalid argument
32 */
34  {
35  public:
36  explicit Invalid_Argument(const std::string& msg);
37 
38  explicit Invalid_Argument(const std::string& msg, const std::string& where);
39 };
40 
41 /**
42 * Unsupported_Argument Exception
43 *
44 * An argument that is invalid because it is not supported by Botan.
45 * It might or might not be valid in another context like a standard.
46 */
48  {
49  public:
50  explicit Unsupported_Argument(const std::string& msg) : Invalid_Argument(msg) {}
51  };
52 
53 /**
54 * Invalid_State Exception
55 */
57  {
58  public:
59  explicit Invalid_State(const std::string& err) : Exception(err) {}
60  };
61 
63  {
64  public:
65  explicit Key_Not_Set(const std::string& algo);
66  };
67 
68 /**
69 * Lookup_Error Exception
70 */
72  {
73  public:
74  explicit Lookup_Error(const std::string& err) : Exception(err) {}
75 
76  Lookup_Error(const std::string& type,
77  const std::string& algo,
78  const std::string& provider);
79  };
80 
81 /**
82 * Internal_Error Exception
83 */
85  {
86  public:
87  explicit Internal_Error(const std::string& err);
88  };
89 
90 /**
91 * Invalid_Key_Length Exception
92 */
94  {
95  public:
96  Invalid_Key_Length(const std::string& name, size_t length);
97  };
98 
99 /**
100 * Invalid_IV_Length Exception
101 */
103  {
104  public:
105  Invalid_IV_Length(const std::string& mode, size_t bad_len);
106  };
107 
108 /**
109 * PRNG_Unseeded Exception
110 */
112  {
113  public:
114  explicit PRNG_Unseeded(const std::string& algo);
115  };
116 
117 /**
118 * Policy_Violation Exception
119 */
121  {
122  public:
123  BOTAN_DEPRECATED("deprecated") explicit Policy_Violation(const std::string& err);
124  };
125 
126 /**
127 * Algorithm_Not_Found Exception
128 */
130  {
131  public:
132  explicit Algorithm_Not_Found(const std::string& name);
133  };
134 
135 /**
136 * No_Provider_Found Exception
137 */
139  {
140  public:
141  BOTAN_DEPRECATED("deprecated") explicit No_Provider_Found(const std::string& name);
142  };
143 
144 /**
145 * Provider_Not_Found is thrown when a specific provider was requested
146 * but that provider is not available.
147 */
149  {
150  public:
151  Provider_Not_Found(const std::string& algo, const std::string& provider);
152  };
153 
154 /**
155 * Invalid_Algorithm_Name Exception
156 */
158  {
159  public:
160  explicit Invalid_Algorithm_Name(const std::string& name);
161  };
162 
163 /**
164 * Encoding_Error Exception
165 */
167  {
168  public:
169  explicit Encoding_Error(const std::string& name);
170  };
171 
172 /**
173 * Decoding_Error Exception
174 */
176  {
177  public:
178  explicit Decoding_Error(const std::string& name);
179 
180  Decoding_Error(const std::string& name, const char* exception_message);
181  };
182 
183 /**
184 * Integrity_Failure Exception
185 */
187  {
188  public:
189  explicit Integrity_Failure(const std::string& msg);
190  };
191 
192 /**
193 * Invalid_OID Exception
194 */
195 class BOTAN_PUBLIC_API(2,0) Invalid_OID final : public Decoding_Error
196  {
197  public:
198  explicit Invalid_OID(const std::string& oid);
199  };
200 
201 /**
202 * Stream_IO_Error Exception
203 */
204 class BOTAN_PUBLIC_API(2,0) Stream_IO_Error final : public Exception
205  {
206  public:
207  explicit Stream_IO_Error(const std::string& err);
208  };
209 
210 /**
211 * Self Test Failure Exception
212 */
214  {
215  public:
216  BOTAN_DEPRECATED("deprecated") explicit Self_Test_Failure(const std::string& err);
217  };
218 
219 /**
220 * Not Implemented Exception
221 */
222 class BOTAN_PUBLIC_API(2,0) Not_Implemented final : public Exception
223  {
224  public:
225  explicit Not_Implemented(const std::string& err);
226  };
227 
228 }
229 
230 #endif
Invalid_State(const std::string &err)
Definition: exceptn.h:59
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
MechanismType type
#define BOTAN_NOEXCEPT
Definition: compiler.h:154
Unsupported_Argument(const std::string &msg)
Definition: exceptn.h:50
const char * what() const BOTAN_NOEXCEPT override
Definition: exceptn.h:25
Definition: alg_id.cpp:13
Lookup_Error(const std::string &err)
Definition: exceptn.h:74