comparison Core/SQLite/OrthancSQLiteException.h @ 1585:9a3e03d6a4d5

fix sqlite standalone build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 19:33:18 +0200
parents 63d47b1fa239
children b1291df2f780
comparison
equal deleted inserted replaced
1584:39ecd34fb1c7 1585:9a3e03d6a4d5
43 43
44 namespace Orthanc 44 namespace Orthanc
45 { 45 {
46 namespace SQLite 46 namespace SQLite
47 { 47 {
48 // Auto-generated by "Resources/GenerateErrorCodes.py"
49 enum ErrorCode
50 {
51 ErrorCode_ParameterOutOfRange,
52 ErrorCode_BadParameterType,
53 ErrorCode_SQLiteNotOpened,
54 ErrorCode_SQLiteAlreadyOpened,
55 ErrorCode_SQLiteCannotOpen,
56 ErrorCode_SQLiteStatementAlreadyUsed,
57 ErrorCode_SQLiteExecute,
58 ErrorCode_SQLiteRollbackWithoutTransaction,
59 ErrorCode_SQLiteCommitWithoutTransaction,
60 ErrorCode_SQLiteRegisterFunction,
61 ErrorCode_SQLiteFlush,
62 ErrorCode_SQLiteCannotRun,
63 ErrorCode_SQLiteCannotStep,
64 ErrorCode_SQLiteBindOutOfRange,
65 ErrorCode_SQLitePrepareStatement,
66 ErrorCode_SQLiteTransactionAlreadyStarted,
67 ErrorCode_SQLiteTransactionCommit,
68 ErrorCode_SQLiteTransactionBegin
69 };
70
48 class OrthancSQLiteException : public ::std::runtime_error 71 class OrthancSQLiteException : public ::std::runtime_error
49 { 72 {
50 public: 73 public:
51 OrthancSQLiteException(const std::string& what) : 74 OrthancSQLiteException(ErrorCode error) :
52 ::std::runtime_error(what) 75 ::std::runtime_error(EnumerationToString(error))
53 { 76 {
54 } 77 }
55 78
56 OrthancSQLiteException(const char* what) : 79 // Auto-generated by "Resources/GenerateErrorCodes.py"
57 ::std::runtime_error(what) 80 static const char* EnumerationToString(ErrorCode code)
58 { 81 {
82 switch (code)
83 {
84 case ErrorCode_ParameterOutOfRange:
85 return "Parameter out of range";
86
87 case ErrorCode_BadParameterType:
88 return "Bad type for a parameter";
89
90 case ErrorCode_SQLiteNotOpened:
91 return "SQLite: The database is not opened";
92
93 case ErrorCode_SQLiteAlreadyOpened:
94 return "SQLite: Connection is already open";
95
96 case ErrorCode_SQLiteCannotOpen:
97 return "SQLite: Unable to open the database";
98
99 case ErrorCode_SQLiteStatementAlreadyUsed:
100 return "SQLite: This cached statement is already being referred to";
101
102 case ErrorCode_SQLiteExecute:
103 return "SQLite: Cannot execute a command";
104
105 case ErrorCode_SQLiteRollbackWithoutTransaction:
106 return "SQLite: Rolling back a nonexistent transaction (have you called Begin()?)";
107
108 case ErrorCode_SQLiteCommitWithoutTransaction:
109 return "SQLite: Committing a nonexistent transaction";
110
111 case ErrorCode_SQLiteRegisterFunction:
112 return "SQLite: Unable to register a function";
113
114 case ErrorCode_SQLiteFlush:
115 return "SQLite: Unable to flush the database";
116
117 case ErrorCode_SQLiteCannotRun:
118 return "SQLite: Cannot run a cached statement";
119
120 case ErrorCode_SQLiteCannotStep:
121 return "SQLite: Cannot step over a cached statement";
122
123 case ErrorCode_SQLiteBindOutOfRange:
124 return "SQLite: Bing a value while out of range (serious error)";
125
126 case ErrorCode_SQLitePrepareStatement:
127 return "SQLite: Cannot prepare a cached statement";
128
129 case ErrorCode_SQLiteTransactionAlreadyStarted:
130 return "SQLite: Beginning the same transaction twice";
131
132 case ErrorCode_SQLiteTransactionCommit:
133 return "SQLite: Failure when committing the transaction";
134
135 case ErrorCode_SQLiteTransactionBegin:
136 return "SQLite: Cannot start a transaction";
137
138 default:
139 return "Unknown error code";
140 }
59 } 141 }
60 }; 142 };
61 } 143 }
62 } 144 }
63 145