Mercurial > hg > orthanc-webviewer
comparison Orthanc/Core/SQLite/OrthancSQLiteException.h @ 78:d6da56f86e5a
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Sep 2015 11:29:17 +0200 |
parents | |
children | 3809121c3290 |
comparison
equal
deleted
inserted
replaced
77:f44ebb25691c | 78:d6da56f86e5a |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * | |
4 * Copyright (C) 2012-2015 Sebastien Jodogne <s.jodogne@gmail.com>, | |
5 * Medical Physics Department, CHU of Liege, Belgium | |
6 * | |
7 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
8 * | |
9 * Redistribution and use in source and binary forms, with or without | |
10 * modification, are permitted provided that the following conditions are | |
11 * met: | |
12 * | |
13 * * Redistributions of source code must retain the above copyright | |
14 * notice, this list of conditions and the following disclaimer. | |
15 * * Redistributions in binary form must reproduce the above | |
16 * copyright notice, this list of conditions and the following disclaimer | |
17 * in the documentation and/or other materials provided with the | |
18 * distribution. | |
19 * * Neither the name of Google Inc., the name of the CHU of Liege, | |
20 * nor the names of its contributors may be used to endorse or promote | |
21 * products derived from this software without specific prior written | |
22 * permission. | |
23 * | |
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
35 **/ | |
36 | |
37 | |
38 #pragma once | |
39 | |
40 | |
41 #if ORTHANC_SQLITE_STANDALONE == 1 | |
42 #include <stdexcept> | |
43 | |
44 namespace Orthanc | |
45 { | |
46 namespace SQLite | |
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 | |
71 class OrthancSQLiteException : public ::std::runtime_error | |
72 { | |
73 public: | |
74 OrthancSQLiteException(ErrorCode error) : | |
75 ::std::runtime_error(EnumerationToString(error)) | |
76 { | |
77 } | |
78 | |
79 // Auto-generated by "Resources/GenerateErrorCodes.py" | |
80 static const char* EnumerationToString(ErrorCode code) | |
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 } | |
141 } | |
142 }; | |
143 } | |
144 } | |
145 | |
146 #else | |
147 # include "../OrthancException.h" | |
148 # define OrthancSQLiteException ::Orthanc::OrthancException | |
149 #endif |