00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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() PQXX_NOEXCEPT =0;
00066
00068
00090 PQXX_CONST virtual const std::exception &base()
00091 const PQXX_NOEXCEPT =0;
00092 };
00093
00094
00096 class PQXX_LIBEXPORT failure :
00097 public pqxx_exception, public std::runtime_error
00098 {
00099 virtual const std::exception &base() const PQXX_NOEXCEPT PQXX_OVERRIDE
00100 { return *this; }
00101 public:
00102 explicit failure(const std::string &);
00103 };
00104
00105
00107
00125 class PQXX_LIBEXPORT broken_connection : public failure
00126 {
00127 public:
00128 broken_connection();
00129 explicit broken_connection(const std::string &);
00130 };
00131
00132
00134
00137 class PQXX_LIBEXPORT sql_error : public failure
00138 {
00140 const std::string m_Q;
00142 const std::string m_sqlstate;
00143
00144 public:
00145 explicit sql_error(
00146 const std::string &msg="",
00147 const std::string &Q="",
00148 const char sqlstate[]=NULL);
00149 virtual ~sql_error() PQXX_NOEXCEPT;
00150
00152 PQXX_PURE const std::string &query() const PQXX_NOEXCEPT;
00153 PQXX_PURE const std::string &sqlstate() const PQXX_NOEXCEPT;
00154 };
00155
00156
00157
00159
00165 class PQXX_LIBEXPORT in_doubt_error : public failure
00166 {
00167 public:
00168 explicit in_doubt_error(const std::string &);
00169 };
00170
00171
00173 class PQXX_LIBEXPORT internal_error :
00174 public pqxx_exception, public std::logic_error
00175 {
00176 virtual const std::exception &base() const PQXX_NOEXCEPT PQXX_OVERRIDE
00177 { return *this; }
00178 public:
00179 explicit internal_error(const std::string &);
00180 };
00181
00182
00184 class PQXX_LIBEXPORT usage_error :
00185 public pqxx_exception, public std::logic_error
00186 {
00187 virtual const std::exception &base() const PQXX_NOEXCEPT PQXX_OVERRIDE
00188 { return *this; }
00189 public:
00190 explicit usage_error(const std::string &);
00191 };
00192
00193
00195 class PQXX_LIBEXPORT argument_error :
00196 public pqxx_exception, public std::invalid_argument
00197 {
00198 virtual const std::exception &base() const PQXX_NOEXCEPT PQXX_OVERRIDE
00199 { return *this; }
00200 public:
00201 explicit argument_error(const std::string &);
00202 };
00203
00204
00206 class PQXX_LIBEXPORT conversion_error :
00207 public pqxx_exception, public std::domain_error
00208 {
00209 virtual const std::exception &base() const PQXX_NOEXCEPT PQXX_OVERRIDE
00210 { return *this; }
00211 public:
00212 explicit conversion_error(const std::string &);
00213 };
00214
00215
00217 class PQXX_LIBEXPORT range_error :
00218 public pqxx_exception, public std::out_of_range
00219 {
00220 virtual const std::exception &base() const PQXX_NOEXCEPT PQXX_OVERRIDE
00221 { return *this; }
00222 public:
00223 explicit range_error(const std::string &);
00224 };
00225
00226
00228 class PQXX_LIBEXPORT feature_not_supported : public sql_error
00229 {
00230 public:
00231 explicit feature_not_supported(
00232 const std::string &err,
00233 const std::string &Q="",
00234 const char sqlstate[]=NULL) :
00235 sql_error(err, Q, sqlstate) {}
00236 };
00237
00239 class PQXX_LIBEXPORT data_exception : public sql_error
00240 {
00241 public:
00242 explicit data_exception(
00243 const std::string &err,
00244 const std::string &Q="",
00245 const char sqlstate[]=NULL) :
00246 sql_error(err, Q, sqlstate) {}
00247 };
00248
00249 class PQXX_LIBEXPORT integrity_constraint_violation : public sql_error
00250 {
00251 public:
00252 explicit integrity_constraint_violation(
00253 const std::string &err,
00254 const std::string &Q="",
00255 const char sqlstate[]=NULL) :
00256 sql_error(err, Q, sqlstate) {}
00257 };
00258
00259 class PQXX_LIBEXPORT restrict_violation :
00260 public integrity_constraint_violation
00261 {
00262 public:
00263 explicit restrict_violation(const std::string &err,
00264 const std::string &Q="",
00265 const char sqlstate[]=NULL) :
00266 integrity_constraint_violation(err, Q, sqlstate) {}
00267 };
00268
00269 class PQXX_LIBEXPORT not_null_violation :
00270 public integrity_constraint_violation
00271 {
00272 public:
00273 explicit not_null_violation(const std::string &err,
00274 const std::string &Q="",
00275 const char sqlstate[]=NULL) :
00276 integrity_constraint_violation(err, Q, sqlstate) {}
00277 };
00278
00279 class PQXX_LIBEXPORT foreign_key_violation :
00280 public integrity_constraint_violation
00281 {
00282 public:
00283 explicit foreign_key_violation(
00284 const std::string &err,
00285 const std::string &Q="",
00286 const char sqlstate[]=NULL) :
00287 integrity_constraint_violation(err, Q, sqlstate) {}
00288 };
00289
00290 class PQXX_LIBEXPORT unique_violation :
00291 public integrity_constraint_violation
00292 {
00293 public:
00294 explicit unique_violation(
00295 const std::string &err,
00296 const std::string &Q="",
00297 const char sqlstate[]=NULL) :
00298 integrity_constraint_violation(err, Q, sqlstate) {}
00299 };
00300
00301 class PQXX_LIBEXPORT check_violation :
00302 public integrity_constraint_violation
00303 {
00304 public:
00305 explicit check_violation(
00306 const std::string &err,
00307 const std::string &Q="",
00308 const char sqlstate[]=NULL) :
00309 integrity_constraint_violation(err, Q, sqlstate) {}
00310 };
00311
00312 class PQXX_LIBEXPORT invalid_cursor_state : public sql_error
00313 {
00314 public:
00315 explicit invalid_cursor_state(
00316 const std::string &err,
00317 const std::string &Q="",
00318 const char sqlstate[]=NULL) :
00319 sql_error(err, Q, sqlstate) {}
00320 };
00321
00322 class PQXX_LIBEXPORT invalid_sql_statement_name : public sql_error
00323 {
00324 public:
00325 explicit invalid_sql_statement_name(
00326 const std::string &err,
00327 const std::string &Q="",
00328 const char sqlstate[]=NULL) :
00329 sql_error(err, Q, sqlstate) {}
00330 };
00331
00332 class PQXX_LIBEXPORT invalid_cursor_name : public sql_error
00333 {
00334 public:
00335 explicit invalid_cursor_name(
00336 const std::string &err,
00337 const std::string &Q="",
00338 const char sqlstate[]=NULL) :
00339 sql_error(err, Q, sqlstate) {}
00340 };
00341
00342 class PQXX_LIBEXPORT syntax_error : public sql_error
00343 {
00344 public:
00346 const int error_position;
00347
00348 explicit syntax_error(
00349 const std::string &err,
00350 const std::string &Q="",
00351 const char sqlstate[]=NULL,
00352 int pos=-1) :
00353 sql_error(err, Q, sqlstate), error_position(pos) {}
00354 };
00355
00356 class PQXX_LIBEXPORT undefined_column : public syntax_error
00357 {
00358 public:
00359 explicit undefined_column(
00360 const std::string &err,
00361 const std::string &Q="",
00362 const char sqlstate[]=NULL) :
00363 syntax_error(err, Q, sqlstate) {}
00364 };
00365
00366 class PQXX_LIBEXPORT undefined_function : public syntax_error
00367 {
00368 public:
00369 explicit undefined_function(
00370 const std::string &err,
00371 const std::string &Q="",
00372 const char sqlstate[]=NULL) :
00373 syntax_error(err, Q, sqlstate) {}
00374 };
00375
00376 class PQXX_LIBEXPORT undefined_table : public syntax_error
00377 {
00378 public:
00379 explicit undefined_table(
00380 const std::string &err,
00381 const std::string &Q="",
00382 const char sqlstate[]=NULL) :
00383 syntax_error(err, Q, sqlstate) {}
00384 };
00385
00386 class PQXX_LIBEXPORT insufficient_privilege : public sql_error
00387 {
00388 public:
00389 explicit insufficient_privilege(
00390 const std::string &err,
00391 const std::string &Q="",
00392 const char sqlstate[]=NULL) :
00393 sql_error(err, Q, sqlstate) {}
00394 };
00395
00397 class PQXX_LIBEXPORT insufficient_resources : public sql_error
00398 {
00399 public:
00400 explicit insufficient_resources(
00401 const std::string &err,
00402 const std::string &Q="",
00403 const char sqlstate[]=NULL) :
00404 sql_error(err,Q) {}
00405 };
00406
00407 class PQXX_LIBEXPORT disk_full : public insufficient_resources
00408 {
00409 public:
00410 explicit disk_full(
00411 const std::string &err,
00412 const std::string &Q="",
00413 const char sqlstate[]=NULL) :
00414 insufficient_resources(err, Q, sqlstate) {}
00415 };
00416
00417 class PQXX_LIBEXPORT out_of_memory : public insufficient_resources
00418 {
00419 public:
00420 explicit out_of_memory(
00421 const std::string &err,
00422 const std::string &Q="",
00423 const char sqlstate[]=NULL) :
00424 insufficient_resources(err, Q, sqlstate) {}
00425 };
00426
00427 class PQXX_LIBEXPORT too_many_connections : public broken_connection
00428 {
00429 public:
00430 explicit too_many_connections(const std::string &err) :
00431 broken_connection(err) {}
00432 };
00433
00435
00437 class PQXX_LIBEXPORT plpgsql_error : public sql_error
00438 {
00439 public:
00440 explicit plpgsql_error(
00441 const std::string &err,
00442 const std::string &Q="",
00443 const char sqlstate[]=NULL) :
00444 sql_error(err, Q, sqlstate) {}
00445 };
00446
00448 class PQXX_LIBEXPORT plpgsql_raise : public plpgsql_error
00449 {
00450 public:
00451 explicit plpgsql_raise(
00452 const std::string &err,
00453 const std::string &Q="",
00454 const char sqlstate[]=NULL) :
00455 plpgsql_error(err, Q, sqlstate) {}
00456 };
00457
00458 class PQXX_LIBEXPORT plpgsql_no_data_found : public plpgsql_error
00459 {
00460 public:
00461 explicit plpgsql_no_data_found(
00462 const std::string &err,
00463 const std::string &Q="",
00464 const char sqlstate[]=NULL) :
00465 plpgsql_error(err, Q, sqlstate) {}
00466 };
00467
00468 class PQXX_LIBEXPORT plpgsql_too_many_rows : public plpgsql_error
00469 {
00470 public:
00471 explicit plpgsql_too_many_rows(
00472 const std::string &err,
00473 const std::string &Q="",
00474 const char sqlstate[]=NULL) :
00475 plpgsql_error(err, Q, sqlstate) {}
00476 };
00477
00482 }
00483
00484 #include "pqxx/compiler-internal-post.hxx"
00485
00486 #endif
00487