libpqxx  4.0.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 PQXX_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 & PQXX_PURE 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:
324  const int error_position;
325 
326  explicit syntax_error(const PGSTD::string &err, int pos=-1) :
327  sql_error(err), error_position(pos) {}
328  syntax_error(const PGSTD::string &err, const PGSTD::string &Q, int pos=-1) :
329  sql_error(err,Q), error_position(pos) {}
330 };
331 
332 class PQXX_LIBEXPORT undefined_column : public syntax_error
333 {
334 public:
335  explicit undefined_column(const PGSTD::string &err) : syntax_error(err) {}
336  undefined_column(const PGSTD::string &err, const PGSTD::string &Q) :
337  syntax_error(err, Q) {}
338 };
339 
340 class PQXX_LIBEXPORT undefined_function : public syntax_error
341 {
342 public:
343  explicit undefined_function(const PGSTD::string &err) : syntax_error(err) {}
344  undefined_function(const PGSTD::string &err, const PGSTD::string &Q) :
345  syntax_error(err, Q) {}
346 };
347 
348 class PQXX_LIBEXPORT undefined_table : public syntax_error
349 {
350 public:
351  explicit undefined_table(const PGSTD::string &err) : syntax_error(err) {}
352  undefined_table(const PGSTD::string &err, const PGSTD::string &Q) :
353  syntax_error(err, Q) {}
354 };
355 
356 class PQXX_LIBEXPORT insufficient_privilege : public sql_error
357 {
358 public:
359  explicit insufficient_privilege(const PGSTD::string &err) : sql_error(err) {}
360  insufficient_privilege(const PGSTD::string &err, const PGSTD::string &Q) :
361  sql_error(err,Q) {}
362 };
363 
365 class PQXX_LIBEXPORT insufficient_resources : public sql_error
366 {
367 public:
368  explicit insufficient_resources(const PGSTD::string &err) : sql_error(err) {}
369  insufficient_resources(const PGSTD::string &err, const PGSTD::string &Q) :
370  sql_error(err,Q) {}
371 };
372 
373 class PQXX_LIBEXPORT disk_full : public insufficient_resources
374 {
375 public:
376  explicit disk_full(const PGSTD::string &err) : insufficient_resources(err) {}
377  disk_full(const PGSTD::string &err, const PGSTD::string &Q) :
378  insufficient_resources(err,Q) {}
379 };
380 
381 class PQXX_LIBEXPORT out_of_memory : public insufficient_resources
382 {
383 public:
384  explicit out_of_memory(const PGSTD::string &err) :
385  insufficient_resources(err) {}
386  out_of_memory(const PGSTD::string &err, const PGSTD::string &Q) :
387  insufficient_resources(err,Q) {}
388 };
389 
390 class PQXX_LIBEXPORT too_many_connections : public broken_connection
391 {
392 public:
393  explicit too_many_connections(const PGSTD::string &err) :
394  broken_connection(err) {}
395 };
396 
398 
400 class PQXX_LIBEXPORT plpgsql_error : public sql_error
401 {
402 public:
403  explicit plpgsql_error(const PGSTD::string &err) :
404  sql_error(err) {}
405  plpgsql_error(const PGSTD::string &err, const PGSTD::string &Q) :
406  sql_error(err, Q) {}
407 };
408 
410 class PQXX_LIBEXPORT plpgsql_raise : public plpgsql_error
411 {
412 public:
413  explicit plpgsql_raise(const PGSTD::string &err) :
414  plpgsql_error(err) {}
415  plpgsql_raise(const PGSTD::string &err, const PGSTD::string &Q) :
416  plpgsql_error(err, Q) {}
417 };
418 
419 class PQXX_LIBEXPORT plpgsql_no_data_found : public plpgsql_error
420 {
421 public:
422  explicit plpgsql_no_data_found(const PGSTD::string &err) :
423  plpgsql_error(err) {}
424  plpgsql_no_data_found(const PGSTD::string &err, const PGSTD::string &Q) :
425  plpgsql_error(err, Q) {}
426 };
427 
428 class PQXX_LIBEXPORT plpgsql_too_many_rows : public plpgsql_error
429 {
430 public:
431  explicit plpgsql_too_many_rows(const PGSTD::string &err) :
432  plpgsql_error(err) {}
433  plpgsql_too_many_rows(const PGSTD::string &err, const PGSTD::string &Q) :
434  plpgsql_error(err, Q) {}
435 };
436 
441 }
442 
443 #include "pqxx/compiler-internal-post.hxx"
444 
445 #endif
446