libpqxx 4.0
|
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 PQXX_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 & PQXX_PURE 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: 00324 const int error_position; 00325 00326 explicit syntax_error(const PGSTD::string &err, int pos=-1) : 00327 sql_error(err), error_position(pos) {} 00328 syntax_error(const PGSTD::string &err, const PGSTD::string &Q, int pos=-1) : 00329 sql_error(err,Q), error_position(pos) {} 00330 }; 00331 00332 class PQXX_LIBEXPORT undefined_column : public syntax_error 00333 { 00334 public: 00335 explicit undefined_column(const PGSTD::string &err) : syntax_error(err) {} 00336 undefined_column(const PGSTD::string &err, const PGSTD::string &Q) : 00337 syntax_error(err, Q) {} 00338 }; 00339 00340 class PQXX_LIBEXPORT undefined_function : public syntax_error 00341 { 00342 public: 00343 explicit undefined_function(const PGSTD::string &err) : syntax_error(err) {} 00344 undefined_function(const PGSTD::string &err, const PGSTD::string &Q) : 00345 syntax_error(err, Q) {} 00346 }; 00347 00348 class PQXX_LIBEXPORT undefined_table : public syntax_error 00349 { 00350 public: 00351 explicit undefined_table(const PGSTD::string &err) : syntax_error(err) {} 00352 undefined_table(const PGSTD::string &err, const PGSTD::string &Q) : 00353 syntax_error(err, Q) {} 00354 }; 00355 00356 class PQXX_LIBEXPORT insufficient_privilege : public sql_error 00357 { 00358 public: 00359 explicit insufficient_privilege(const PGSTD::string &err) : sql_error(err) {} 00360 insufficient_privilege(const PGSTD::string &err, const PGSTD::string &Q) : 00361 sql_error(err,Q) {} 00362 }; 00363 00365 class PQXX_LIBEXPORT insufficient_resources : public sql_error 00366 { 00367 public: 00368 explicit insufficient_resources(const PGSTD::string &err) : sql_error(err) {} 00369 insufficient_resources(const PGSTD::string &err, const PGSTD::string &Q) : 00370 sql_error(err,Q) {} 00371 }; 00372 00373 class PQXX_LIBEXPORT disk_full : public insufficient_resources 00374 { 00375 public: 00376 explicit disk_full(const PGSTD::string &err) : insufficient_resources(err) {} 00377 disk_full(const PGSTD::string &err, const PGSTD::string &Q) : 00378 insufficient_resources(err,Q) {} 00379 }; 00380 00381 class PQXX_LIBEXPORT out_of_memory : public insufficient_resources 00382 { 00383 public: 00384 explicit out_of_memory(const PGSTD::string &err) : 00385 insufficient_resources(err) {} 00386 out_of_memory(const PGSTD::string &err, const PGSTD::string &Q) : 00387 insufficient_resources(err,Q) {} 00388 }; 00389 00390 class PQXX_LIBEXPORT too_many_connections : public broken_connection 00391 { 00392 public: 00393 explicit too_many_connections(const PGSTD::string &err) : 00394 broken_connection(err) {} 00395 }; 00396 00398 00400 class PQXX_LIBEXPORT plpgsql_error : public sql_error 00401 { 00402 public: 00403 explicit plpgsql_error(const PGSTD::string &err) : 00404 sql_error(err) {} 00405 plpgsql_error(const PGSTD::string &err, const PGSTD::string &Q) : 00406 sql_error(err, Q) {} 00407 }; 00408 00410 class PQXX_LIBEXPORT plpgsql_raise : public plpgsql_error 00411 { 00412 public: 00413 explicit plpgsql_raise(const PGSTD::string &err) : 00414 plpgsql_error(err) {} 00415 plpgsql_raise(const PGSTD::string &err, const PGSTD::string &Q) : 00416 plpgsql_error(err, Q) {} 00417 }; 00418 00419 class PQXX_LIBEXPORT plpgsql_no_data_found : public plpgsql_error 00420 { 00421 public: 00422 explicit plpgsql_no_data_found(const PGSTD::string &err) : 00423 plpgsql_error(err) {} 00424 plpgsql_no_data_found(const PGSTD::string &err, const PGSTD::string &Q) : 00425 plpgsql_error(err, Q) {} 00426 }; 00427 00428 class PQXX_LIBEXPORT plpgsql_too_many_rows : public plpgsql_error 00429 { 00430 public: 00431 explicit plpgsql_too_many_rows(const PGSTD::string &err) : 00432 plpgsql_error(err) {} 00433 plpgsql_too_many_rows(const PGSTD::string &err, const PGSTD::string &Q) : 00434 plpgsql_error(err, Q) {} 00435 }; 00436 00441 } 00442 00443 #include "pqxx/compiler-internal-post.hxx" 00444 00445 #endif 00446