ctkPluginDatabaseException.h

Go to the documentation of this file.
00001 /*=============================================================================
00002 
00003   Library: CTK
00004 
00005   Copyright (c) 2010 German Cancer Research Center,
00006     Division of Medical and Biological Informatics
00007 
00008   Licensed under the Apache License, Version 2.0 (the "License");
00009   you may not use this file except in compliance with the License.
00010   You may obtain a copy of the License at
00011 
00012     http://www.apache.org/licenses/LICENSE-2.0
00013 
00014   Unless required by applicable law or agreed to in writing, software
00015   distributed under the License is distributed on an "AS IS" BASIS,
00016   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017   See the License for the specific language governing permissions and
00018   limitations under the License.
00019 
00020 =============================================================================*/
00021 
00022 #ifndef CTKPLUGINDATABASEEXCEPTION_H
00023 #define CTKPLUGINDATABASEEXCEPTION_H
00024 
00025 #include "CTKPluginFrameworkExport.h"
00026 
00027 #include <stdexcept>
00028 
00029 #include <QString>
00030 
00031 
00032 class CTK_PLUGINFW_EXPORT ctkPluginDatabaseException : public std::runtime_error
00033 {
00034 public:
00035 
00036   enum Type {
00037     UNSPECIFIED,
00038     DB_CONNECTION_INVALID,
00039     DB_NOT_OPEN_ERROR,
00040     DB_NOT_FOUND_ERROR,
00041     DB_CREATE_DIR_ERROR,
00042     DB_WRITE_ERROR,
00043     DB_FILE_INVALID,
00044     DB_SQL_ERROR
00045   };
00046 
00047   ctkPluginDatabaseException(const QString& msg, const Type& type = UNSPECIFIED, const std::exception& cause = std::exception());
00048   ctkPluginDatabaseException(const QString& msg, const std::exception& cause);
00049 
00050   ctkPluginDatabaseException(const ctkPluginDatabaseException& o);
00051   ctkPluginDatabaseException& operator=(const ctkPluginDatabaseException& o);
00052 
00053   ~ctkPluginDatabaseException() throw() {}
00054 
00055   std::exception getCause() const;
00056   void setCause(const std::exception&) throw(std::logic_error);
00057   Type getType() const;
00058 
00059 
00060 private:
00061 
00062   Type type;
00063   std::exception cause;
00064 };
00065 
00066 
00067 CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug dbg, const ctkPluginDatabaseException& exc);
00068 
00069 #endif // CTKPLUGINDATABASEEXCEPTION_H
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines