ctkPluginDatabaseException.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKPLUGINDATABASEEXCEPTION_H
  16. #define CTKPLUGINDATABASEEXCEPTION_H
  17. #include "CTKCoreExport.h"
  18. #include <stdexcept>
  19. #include <QString>
  20. namespace ctk {
  21. class CTK_CORE_EXPORT PluginDatabaseException : public std::runtime_error
  22. {
  23. public:
  24. enum Type {
  25. UNSPECIFIED,
  26. DB_CONNECTION_INVALID,
  27. DB_NOT_OPEN_ERROR,
  28. DB_NOT_FOUND_ERROR,
  29. DB_CREATE_DIR_ERROR,
  30. DB_WRITE_ERROR,
  31. DB_FILE_INVALID,
  32. DB_SQL_ERROR
  33. };
  34. PluginDatabaseException(const QString& msg, const Type& type = UNSPECIFIED, const std::exception& cause = std::exception());
  35. PluginDatabaseException(const QString& msg, const std::exception& cause);
  36. PluginDatabaseException(const PluginDatabaseException& o);
  37. PluginDatabaseException& operator=(const PluginDatabaseException& o);
  38. ~PluginDatabaseException() throw() {}
  39. std::exception getCause() const;
  40. void setCause(const std::exception&) throw(std::logic_error);
  41. Type getType() const;
  42. private:
  43. Type type;
  44. std::exception cause;
  45. };
  46. }
  47. CTK_CORE_EXPORT QDebug operator<<(QDebug dbg, const ctk::PluginDatabaseException& exc);
  48. #endif // CTKPLUGINDATABASEEXCEPTION_H