# except.hxx

    00001 /*-------------------------------------------------------------------------
    00002  *
    00003  *   FILE
    00004  *      pqxx/except.hxx
    00005  *
    00006  *   DESCRIPTION
    00007  *      definition of libpqxx exception classes
    00008  *   pqxx::sql_error, pqxx::broken_connection, pqxx::in_doubt_error, ...
    00009  *   DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/except instead.
    00010  *
    00011  * Copyright (c) 2003-2008, Jeroen T. Vermeulen <jtv@xs4all.nl>
    00012  *
    00013  * See COPYING for copyright license.  If you did not receive a file called
    00014  * COPYING with this source code, please notify the distributor of this mistake,
    00015  * or contact the author.
    00016  *
    00017  *-------------------------------------------------------------------------
    00018  */
    00019 #ifndef PQXX_H_EXCEPT
    00020 #define PQXX_H_EXCEPT
    00021
    00022 #include "pqxx/compiler-public.hxx"
    00023 #include "pqxx/compiler-internal-pre.hxx"
    00024
    00025 #include <stdexcept>
    00026
    00027 #include "pqxx/util"
    00028
    00029
    00030 namespace pqxx
    00031 {
    00032
    00049
    00050
    00061 class PQXX_LIBEXPORT PQXX_NOVTABLE pqxx_exception
    00062 {
    00063 public:
    00065   virtual ~pqxx_exception() throw () =0;
    00066
    00068
    00090   virtual const PGSTD::exception &base() const throw () =0;             //[t0]
    00091 };
    00092
    00093
    00095 class PQXX_LIBEXPORT failure :
    00096   public pqxx_exception, public PGSTD::runtime_error
    00097 {
    00098   virtual const PGSTD::exception &base() const throw () { return *this; }
    00099 public:
    00100   explicit failure(const PGSTD::string &);
    00101 };
    00102
    00103
    00105
    00123 class PQXX_LIBEXPORT broken_connection : public failure
    00124 {
    00125 public:
    00126   broken_connection();
    00127   explicit broken_connection(const PGSTD::string &);
    00128 };
    00129
    00130
    00132
    00133 class PQXX_LIBEXPORT sql_error : public failure
    00134 {
    00135   PGSTD::string m_Q;
    00136
    00137 public:
    00138   sql_error();
    00139   explicit sql_error(const PGSTD::string &);
    00140   sql_error(const PGSTD::string &, const PGSTD::string &Q);
    00141   virtual ~sql_error() throw ();
    00142
    00144   const PGSTD::string &query() const throw ();                          //[t56]
    00145 };
    00146
    00147
    00148 // TODO: should this be called statement_completion_unknown!?
    00150
    00156 class PQXX_LIBEXPORT in_doubt_error : public failure
    00157 {
    00158 public:
    00159   explicit in_doubt_error(const PGSTD::string &);
    00160 };
    00161
    00162
    00164 class PQXX_LIBEXPORT internal_error :
    00165   public pqxx_exception, public PGSTD::logic_error
    00166 {
    00167   virtual const PGSTD::exception &base() const throw () { return *this; }
    00168 public:
    00169   explicit internal_error(const PGSTD::string &);
    00170 };
    00171
    00172
    00174 class PQXX_LIBEXPORT usage_error :
    00175   public pqxx_exception, public PGSTD::logic_error
    00176 {
    00177   virtual const PGSTD::exception &base() const throw () { return *this; }
    00178 public:
    00179   explicit usage_error(const PGSTD::string &);
    00180 };
    00181
    00182
    00184 class PQXX_LIBEXPORT argument_error :
    00185   public pqxx_exception, public PGSTD::invalid_argument
    00186 {
    00187   virtual const PGSTD::exception &base() const throw () { return *this; }
    00188 public:
    00189   explicit argument_error(const PGSTD::string &);
    00190 };
    00191
    00192
    00193 class PQXX_LIBEXPORT conversion_error :
    00194   public pqxx_exception, public PGSTD::domain_error
    00195 {
    00196   virtual const PGSTD::exception &base() const throw () { return *this; }
    00197 public:
    00198   explicit conversion_error(const PGSTD::string &);
    00199 };
    00200
    00201
    00203 class PQXX_LIBEXPORT range_error :
    00204   public pqxx_exception, public PGSTD::out_of_range
    00205 {
    00206   virtual const PGSTD::exception &base() const throw () { return *this; }
    00207 public:
    00208   explicit range_error(const PGSTD::string &);
    00209 };
    00210
    00211
    00213 class PQXX_LIBEXPORT feature_not_supported : public sql_error
    00214 {
    00215 public:
    00216   explicit feature_not_supported(const PGSTD::string &err) : sql_error(err) {}
    00217   feature_not_supported(const PGSTD::string &err, const PGSTD::string &Q) :
    00218         sql_error(err,Q) {}
    00219 };
    00220
    00222 class PQXX_LIBEXPORT data_exception : public sql_error
    00223 {
    00224 public:
    00225   explicit data_exception(const PGSTD::string &err) : sql_error(err) {}
    00226   data_exception(const PGSTD::string &err, const PGSTD::string &Q) :
    00227         sql_error(err,Q) {}
    00228 };
    00229
    00230 class PQXX_LIBEXPORT integrity_constraint_violation : public sql_error
    00231 {
    00232 public:
    00233   explicit integrity_constraint_violation(const PGSTD::string &err) :
    00234         sql_error(err) {}
    00235   integrity_constraint_violation(const PGSTD::string &err,
    00236         const PGSTD::string &Q) :
    00237         sql_error(err, Q) {}
    00238 };
    00239
    00240 class PQXX_LIBEXPORT restrict_violation :
    00241   public integrity_constraint_violation
    00242 {
    00243 public:
    00244   explicit restrict_violation(const PGSTD::string &err) :
    00245         integrity_constraint_violation(err) {}
    00246   restrict_violation(const PGSTD::string &err,
    00247         const PGSTD::string &Q) :
    00248         integrity_constraint_violation(err, Q) {}
    00249 };
    00250
    00251 class PQXX_LIBEXPORT not_null_violation :
    00252   public integrity_constraint_violation
    00253 {
    00254 public:
    00255   explicit not_null_violation(const PGSTD::string &err) :
    00256         integrity_constraint_violation(err) {}
    00257   not_null_violation(const PGSTD::string &err,
    00258         const PGSTD::string &Q) :
    00259         integrity_constraint_violation(err, Q) {}
    00260 };
    00261
    00262 class PQXX_LIBEXPORT foreign_key_violation :
    00263   public integrity_constraint_violation
    00264 {
    00265 public:
    00266   explicit foreign_key_violation(const PGSTD::string &err) :
    00267         integrity_constraint_violation(err) {}
    00268   foreign_key_violation(const PGSTD::string &err,
    00269         const PGSTD::string &Q) :
    00270         integrity_constraint_violation(err, Q) {}
    00271 };
    00272
    00273 class PQXX_LIBEXPORT unique_violation :
    00274   public integrity_constraint_violation
    00275 {
    00276 public:
    00277   explicit unique_violation(const PGSTD::string &err) :
    00278         integrity_constraint_violation(err) {}
    00279   unique_violation(const PGSTD::string &err,
    00280         const PGSTD::string &Q) :
    00281         integrity_constraint_violation(err, Q) {}
    00282 };
    00283
    00284 class PQXX_LIBEXPORT check_violation :
    00285   public integrity_constraint_violation
    00286 {
    00287 public:
    00288   explicit check_violation(const PGSTD::string &err) :
    00289         integrity_constraint_violation(err) {}
    00290   check_violation(const PGSTD::string &err,
    00291         const PGSTD::string &Q) :
    00292         integrity_constraint_violation(err, Q) {}
    00293 };
    00294
    00295 class PQXX_LIBEXPORT invalid_cursor_state : public sql_error
    00296 {
    00297 public:
    00298   explicit invalid_cursor_state(const PGSTD::string &err) : sql_error(err) {}
    00299   invalid_cursor_state(const PGSTD::string &err, const PGSTD::string &Q) :
    00300         sql_error(err,Q) {}
    00301 };
    00302
    00303 class PQXX_LIBEXPORT invalid_sql_statement_name : public sql_error
    00304 {
    00305 public:
    00306   explicit invalid_sql_statement_name(const PGSTD::string &err) :
    00307         sql_error(err) {}
    00308   invalid_sql_statement_name(const PGSTD::string &err, const PGSTD::string &Q) :
    00309         sql_error(err,Q) {}
    00310 };
    00311
    00312 class PQXX_LIBEXPORT invalid_cursor_name : public sql_error
    00313 {
    00314 public:
    00315   explicit invalid_cursor_name(const PGSTD::string &err) : sql_error(err) {}
    00316   invalid_cursor_name(const PGSTD::string &err, const PGSTD::string &Q) :
    00317         sql_error(err,Q) {}
    00318 };
    00319
    00320 class PQXX_LIBEXPORT syntax_error : public sql_error
    00321 {
    00322 public:
    00323   explicit syntax_error(const PGSTD::string &err) : sql_error(err) {}
    00324   syntax_error(const PGSTD::string &err, const PGSTD::string &Q) :
    00325         sql_error(err,Q) {}
    00326 };
    00327
    00328 class PQXX_LIBEXPORT undefined_column : public syntax_error
    00329 {
    00330 public:
    00331   explicit undefined_column(const PGSTD::string &err) : syntax_error(err) {}
    00332   undefined_column(const PGSTD::string &err, const PGSTD::string &Q) :
    00333     syntax_error(err, Q) {}
    00334 };
    00335
    00336 class PQXX_LIBEXPORT undefined_function : public syntax_error
    00337 {
    00338 public:
    00339   explicit undefined_function(const PGSTD::string &err) : syntax_error(err) {}
    00340   undefined_function(const PGSTD::string &err, const PGSTD::string &Q) :
    00341     syntax_error(err, Q) {}
    00342 };
    00343
    00344 class PQXX_LIBEXPORT undefined_table : public syntax_error
    00345 {
    00346 public:
    00347   explicit undefined_table(const PGSTD::string &err) : syntax_error(err) {}
    00348   undefined_table(const PGSTD::string &err, const PGSTD::string &Q) :
    00349     syntax_error(err, Q) {}
    00350 };
    00351
    00352 class PQXX_LIBEXPORT insufficient_privilege : public sql_error
    00353 {
    00354 public:
    00355   explicit insufficient_privilege(const PGSTD::string &err) : sql_error(err) {}
    00356   insufficient_privilege(const PGSTD::string &err, const PGSTD::string &Q) :
    00357         sql_error(err,Q) {}
    00358 };
    00359
    00361 class PQXX_LIBEXPORT insufficient_resources : public sql_error
    00362 {
    00363 public:
    00364   explicit insufficient_resources(const PGSTD::string &err) : sql_error(err) {}
    00365   insufficient_resources(const PGSTD::string &err, const PGSTD::string &Q) :
    00366         sql_error(err,Q) {}
    00367 };
    00368
    00369 class PQXX_LIBEXPORT disk_full : public insufficient_resources
    00370 {
    00371 public:
    00372   explicit disk_full(const PGSTD::string &err) : insufficient_resources(err) {}
    00373   disk_full(const PGSTD::string &err, const PGSTD::string &Q) :
    00374         insufficient_resources(err,Q) {}
    00375 };
    00376
    00377 class PQXX_LIBEXPORT out_of_memory : public insufficient_resources
    00378 {
    00379 public:
    00380   explicit out_of_memory(const PGSTD::string &err) :
    00381         insufficient_resources(err) {}
    00382   out_of_memory(const PGSTD::string &err, const PGSTD::string &Q) :
    00383         insufficient_resources(err,Q) {}
    00384 };
    00385
    00386 class PQXX_LIBEXPORT too_many_connections : public broken_connection
    00387 {
    00388 public:
    00389   explicit too_many_connections(const PGSTD::string &err) :
    00390         broken_connection(err) {}
    00391 };
    00392
    00394
    00396 class PQXX_LIBEXPORT plpgsql_error : public sql_error
    00397 {
    00398 public:
    00399   explicit plpgsql_error(const PGSTD::string &err) :
    00400     sql_error(err) {}
    00401   plpgsql_error(const PGSTD::string &err, const PGSTD::string &Q) :
    00402     sql_error(err, Q) {}
    00403 };
    00404
    00406 class PQXX_LIBEXPORT plpgsql_raise : public plpgsql_error
    00407 {
    00408 public:
    00409   explicit plpgsql_raise(const PGSTD::string &err) :
    00410     plpgsql_error(err) {}
    00411   plpgsql_raise(const PGSTD::string &err, const PGSTD::string &Q) :
    00412     plpgsql_error(err, Q) {}
    00413 };
    00414
    00415 class PQXX_LIBEXPORT plpgsql_no_data_found : public plpgsql_error
    00416 {
    00417 public:
    00418   explicit plpgsql_no_data_found(const PGSTD::string &err) :
    00419     plpgsql_error(err) {}
    00420   plpgsql_no_data_found(const PGSTD::string &err, const PGSTD::string &Q) :
    00421     plpgsql_error(err, Q) {}
    00422 };
    00423
    00424 class PQXX_LIBEXPORT plpgsql_too_many_rows : public plpgsql_error
    00425 {
    00426 public:
    00427   explicit plpgsql_too_many_rows(const PGSTD::string &err) :
    00428     plpgsql_error(err) {}
    00429   plpgsql_too_many_rows(const PGSTD::string &err, const PGSTD::string &Q) :
    00430     plpgsql_error(err, Q) {}
    00431 };
    00432
    00437 }
    00438
    00439 #include "pqxx/compiler-internal-post.hxx"
    00440
    00441 #endif
    00442