libpqxx  3.1.1
except.hxx
1 /*-------------------------------------------------------------------------
2  *
3  * FILE
4  * pqxx/except.hxx
5  *
6  * DESCRIPTION
7  * definition of libpqxx exception classes
8  * pqxx::sql_error, pqxx::broken_connection, pqxx::in_doubt_error, ...
9  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/except instead.
10  *
11  * Copyright (c) 2003-2008, Jeroen T. Vermeulen <jtv@xs4all.nl>
12  *
13  * See COPYING for copyright license. If you did not receive a file called
14  * COPYING with this source code, please notify the distributor of this mistake,
15  * or contact the author.
16  *
17  *-------------------------------------------------------------------------
18  */
19 #ifndef PQXX_H_EXCEPT
20 #define PQXX_H_EXCEPT
21 
22 #include "pqxx/compiler-public.hxx"
23 #include "pqxx/compiler-internal-pre.hxx"
24 
25 #include <stdexcept>
26 
27 #include "pqxx/util"
28 
29 
30 namespace pqxx
31 {
32 
49 
50 
61 class PQXX_LIBEXPORT PQXX_NOVTABLE pqxx_exception
62 {
63 public:
65  virtual ~pqxx_exception() throw () =0;
66 
68 
90  virtual const PGSTD::exception &base() const throw () =0; //[t0]
91 };
92 
93 
95 class PQXX_LIBEXPORT failure :
96  public pqxx_exception, public PGSTD::runtime_error
97 {
98  virtual const PGSTD::exception &base() const throw () { return *this; }
99 public:
100  explicit failure(const PGSTD::string &);
101 };
102 
103 
105 
123 class PQXX_LIBEXPORT broken_connection : public failure
124 {
125 public:
127  explicit broken_connection(const PGSTD::string &);
128 };
129 
130 
132 
133 class PQXX_LIBEXPORT sql_error : public failure
134 {
135  PGSTD::string m_Q;
136 
137 public:
138  sql_error();
139  explicit sql_error(const PGSTD::string &);
140  sql_error(const PGSTD::string &, const PGSTD::string &Q);
141  virtual ~sql_error() throw ();
142 
144  const PGSTD::string &query() const throw (); //[t56]
145 };
146 
147 
148 // TODO: should this be called statement_completion_unknown!?
150 
156 class PQXX_LIBEXPORT in_doubt_error : public failure
157 {
158 public:
159  explicit in_doubt_error(const PGSTD::string &);
160 };
161 
162 
164 class PQXX_LIBEXPORT internal_error :
165  public pqxx_exception, public PGSTD::logic_error
166 {
167  virtual const PGSTD::exception &base() const throw () { return *this; }
168 public:
169  explicit internal_error(const PGSTD::string &);
170 };
171 
172 
174 class PQXX_LIBEXPORT usage_error :
175  public pqxx_exception, public PGSTD::logic_error
176 {
177  virtual const PGSTD::exception &base() const throw () { return *this; }
178 public:
179  explicit usage_error(const PGSTD::string &);
180 };
181 
182 
184 class PQXX_LIBEXPORT argument_error :
185  public pqxx_exception, public PGSTD::invalid_argument
186 {
187  virtual const PGSTD::exception &base() const throw () { return *this; }
188 public:
189  explicit argument_error(const PGSTD::string &);
190 };
191 
192 
193 class PQXX_LIBEXPORT conversion_error :
194  public pqxx_exception, public PGSTD::domain_error
195 {
196  virtual const PGSTD::exception &base() const throw () { return *this; }
197 public:
198  explicit conversion_error(const PGSTD::string &);
199 };
200 
201 
203 class PQXX_LIBEXPORT range_error :
204  public pqxx_exception, public PGSTD::out_of_range
205 {
206  virtual const PGSTD::exception &base() const throw () { return *this; }
207 public:
208  explicit range_error(const PGSTD::string &);
209 };
210 
211 
213 class PQXX_LIBEXPORT feature_not_supported : public sql_error
214 {
215 public:
216  explicit feature_not_supported(const PGSTD::string &err) : sql_error(err) {}
217  feature_not_supported(const PGSTD::string &err, const PGSTD::string &Q) :
218  sql_error(err,Q) {}
219 };
220 
222 class PQXX_LIBEXPORT data_exception : public sql_error
223 {
224 public:
225  explicit data_exception(const PGSTD::string &err) : sql_error(err) {}
226  data_exception(const PGSTD::string &err, const PGSTD::string &Q) :
227  sql_error(err,Q) {}
228 };
229 
230 class PQXX_LIBEXPORT integrity_constraint_violation : public sql_error
231 {
232 public:
233  explicit integrity_constraint_violation(const PGSTD::string &err) :
234  sql_error(err) {}
235  integrity_constraint_violation(const PGSTD::string &err,
236  const PGSTD::string &Q) :
237  sql_error(err, Q) {}
238 };
239 
240 class PQXX_LIBEXPORT restrict_violation :
242 {
243 public:
244  explicit restrict_violation(const PGSTD::string &err) :
246  restrict_violation(const PGSTD::string &err,
247  const PGSTD::string &Q) :
249 };
250 
251 class PQXX_LIBEXPORT not_null_violation :
253 {
254 public:
255  explicit not_null_violation(const PGSTD::string &err) :
257  not_null_violation(const PGSTD::string &err,
258  const PGSTD::string &Q) :
260 };
261 
262 class PQXX_LIBEXPORT foreign_key_violation :
264 {
265 public:
266  explicit foreign_key_violation(const PGSTD::string &err) :
268  foreign_key_violation(const PGSTD::string &err,
269  const PGSTD::string &Q) :
271 };
272 
273 class PQXX_LIBEXPORT unique_violation :
275 {
276 public:
277  explicit unique_violation(const PGSTD::string &err) :
279  unique_violation(const PGSTD::string &err,
280  const PGSTD::string &Q) :
282 };
283 
284 class PQXX_LIBEXPORT check_violation :
286 {
287 public:
288  explicit check_violation(const PGSTD::string &err) :
290  check_violation(const PGSTD::string &err,
291  const PGSTD::string &Q) :
293 };
294 
295 class PQXX_LIBEXPORT invalid_cursor_state : public sql_error
296 {
297 public:
298  explicit invalid_cursor_state(const PGSTD::string &err) : sql_error(err) {}
299  invalid_cursor_state(const PGSTD::string &err, const PGSTD::string &Q) :
300  sql_error(err,Q) {}
301 };
302 
303 class PQXX_LIBEXPORT invalid_sql_statement_name : public sql_error
304 {
305 public:
306  explicit invalid_sql_statement_name(const PGSTD::string &err) :
307  sql_error(err) {}
308  invalid_sql_statement_name(const PGSTD::string &err, const PGSTD::string &Q) :
309  sql_error(err,Q) {}
310 };
311 
312 class PQXX_LIBEXPORT invalid_cursor_name : public sql_error
313 {
314 public:
315  explicit invalid_cursor_name(const PGSTD::string &err) : sql_error(err) {}
316  invalid_cursor_name(const PGSTD::string &err, const PGSTD::string &Q) :
317  sql_error(err,Q) {}
318 };
319 
320 class PQXX_LIBEXPORT syntax_error : public sql_error
321 {
322 public:
323  explicit syntax_error(const PGSTD::string &err) : sql_error(err) {}
324  syntax_error(const PGSTD::string &err, const PGSTD::string &Q) :
325  sql_error(err,Q) {}
326 };
327 
328 class PQXX_LIBEXPORT undefined_column : public syntax_error
329 {
330 public:
331  explicit undefined_column(const PGSTD::string &err) : syntax_error(err) {}
332  undefined_column(const PGSTD::string &err, const PGSTD::string &Q) :
333  syntax_error(err, Q) {}
334 };
335 
336 class PQXX_LIBEXPORT undefined_function : public syntax_error
337 {
338 public:
339  explicit undefined_function(const PGSTD::string &err) : syntax_error(err) {}
340  undefined_function(const PGSTD::string &err, const PGSTD::string &Q) :
341  syntax_error(err, Q) {}
342 };
343 
344 class PQXX_LIBEXPORT undefined_table : public syntax_error
345 {
346 public:
347  explicit undefined_table(const PGSTD::string &err) : syntax_error(err) {}
348  undefined_table(const PGSTD::string &err, const PGSTD::string &Q) :
349  syntax_error(err, Q) {}
350 };
351 
352 class PQXX_LIBEXPORT insufficient_privilege : public sql_error
353 {
354 public:
355  explicit insufficient_privilege(const PGSTD::string &err) : sql_error(err) {}
356  insufficient_privilege(const PGSTD::string &err, const PGSTD::string &Q) :
357  sql_error(err,Q) {}
358 };
359 
361 class PQXX_LIBEXPORT insufficient_resources : public sql_error
362 {
363 public:
364  explicit insufficient_resources(const PGSTD::string &err) : sql_error(err) {}
365  insufficient_resources(const PGSTD::string &err, const PGSTD::string &Q) :
366  sql_error(err,Q) {}
367 };
368 
369 class PQXX_LIBEXPORT disk_full : public insufficient_resources
370 {
371 public:
372  explicit disk_full(const PGSTD::string &err) : insufficient_resources(err) {}
373  disk_full(const PGSTD::string &err, const PGSTD::string &Q) :
374  insufficient_resources(err,Q) {}
375 };
376 
377 class PQXX_LIBEXPORT out_of_memory : public insufficient_resources
378 {
379 public:
380  explicit out_of_memory(const PGSTD::string &err) :
381  insufficient_resources(err) {}
382  out_of_memory(const PGSTD::string &err, const PGSTD::string &Q) :
383  insufficient_resources(err,Q) {}
384 };
385 
386 class PQXX_LIBEXPORT too_many_connections : public broken_connection
387 {
388 public:
389  explicit too_many_connections(const PGSTD::string &err) :
390  broken_connection(err) {}
391 };
392 
394 
396 class PQXX_LIBEXPORT plpgsql_error : public sql_error
397 {
398 public:
399  explicit plpgsql_error(const PGSTD::string &err) :
400  sql_error(err) {}
401  plpgsql_error(const PGSTD::string &err, const PGSTD::string &Q) :
402  sql_error(err, Q) {}
403 };
404 
406 class PQXX_LIBEXPORT plpgsql_raise : public plpgsql_error
407 {
408 public:
409  explicit plpgsql_raise(const PGSTD::string &err) :
410  plpgsql_error(err) {}
411  plpgsql_raise(const PGSTD::string &err, const PGSTD::string &Q) :
412  plpgsql_error(err, Q) {}
413 };
414 
415 class PQXX_LIBEXPORT plpgsql_no_data_found : public plpgsql_error
416 {
417 public:
418  explicit plpgsql_no_data_found(const PGSTD::string &err) :
419  plpgsql_error(err) {}
420  plpgsql_no_data_found(const PGSTD::string &err, const PGSTD::string &Q) :
421  plpgsql_error(err, Q) {}
422 };
423 
424 class PQXX_LIBEXPORT plpgsql_too_many_rows : public plpgsql_error
425 {
426 public:
427  explicit plpgsql_too_many_rows(const PGSTD::string &err) :
428  plpgsql_error(err) {}
429  plpgsql_too_many_rows(const PGSTD::string &err, const PGSTD::string &Q) :
430  plpgsql_error(err, Q) {}
431 };
432 
437 }
438 
439 #include "pqxx/compiler-internal-post.hxx"
440 
441 #endif
442