LiteSQL
except.hpp
Go to the documentation of this file.
1 /* LiteSQL
2  *
3  * The list of contributors at http://litesql.sf.net/
4  *
5  * See LICENSE for copyright information. */
6 
7 #ifndef _litesql_except_hpp
8 #define _litesql_except_hpp
9 
10 #include <iostream>
11 #include <exception>
12 #include "litesql/utils.hpp"
13 
16 namespace litesql {
18 class Except : public std::exception {
19 private:
20  std::string msg;
21 public:
22  Except(const std::string& m) throw() : msg(m) {}
23  virtual ~Except(void) throw() {}
24  virtual const char* what() const throw() {
25  return msg.c_str();
26  }
27  friend std::ostream &operator<<(std::ostream &os, const Except &e) {
28  os << e.msg.c_str();
29  return os;
30  }
31 };
33 class NotFound : public Except {
34 public:
35  NotFound(const std::string& s="") : Except("NotFound: "+s) {}
36 };
38 class DatabaseError : public Except {
39 public:
40  DatabaseError(const std::string& m) : Except("DatabaseError: "+m) {}
41 };
43 class SQLError : public Except {
44 public:
45  SQLError(const std::string& m) : Except("SQLError: "+m) {}
46 };
48 class InternalError : public Except {
49 public:
50  InternalError(const std::string& m) : Except("InternalError: " +m) {}
51 };
53 class MemoryError : public Except {
54 public:
55  MemoryError(const std::string& m) : Except("Allocation failed: "+m){}
56 };
58 class InsertionError : public Except {
59 public:
60  InsertionError(const std::string& m) : Except("Database full: "+m){}
61 };
62 
63 class ConstraintError : public Except {
64 public:
65  ConstraintError(const std::string& m) : Except("Contraint error: "+m){}
66 };
67 
69 class UnknownError : public Except {
70  // handles the rest
71 public:
72  UnknownError(const std::string& m) : Except("UnknownError: "+m){}
73 };
74 
75 
76 }
77 #endif
litesql::SQLError
exception thrown when SQL statement cannot be executed
Definition: except.hpp:43
litesql::Except
base class for exceptions
Definition: except.hpp:18
litesql::InsertionError
exception thrown when database (disk) is full
Definition: except.hpp:58
utils.hpp
litesql::UnknownError
exception thrown when none of other exceptions match
Definition: except.hpp:69
litesql::ConstraintError
Definition: except.hpp:63
litesql::NotFound
exception thrown when a record is not found
Definition: except.hpp:33
litesql::MemoryError
exception thrown when backend cannot allocate memory
Definition: except.hpp:53
litesql::InternalError
exception thrown when backend produces internal error
Definition: except.hpp:48
litesql::DatabaseError
exception thrown when database cannot be accessed
Definition: except.hpp:38

SourceForge.net Logo