ctkPluginException.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 CTKPLUGINEXCEPTION_H
  16. #define CTKPLUGINEXCEPTION_H
  17. #include <stdexcept>
  18. #include <QString>
  19. #include <QDebug>
  20. #include "CTKCoreExport.h"
  21. namespace ctk {
  22. class CTK_CORE_EXPORT PluginException : public std::runtime_error
  23. {
  24. public:
  25. enum Type {
  26. /**
  27. * No exception type is unspecified.
  28. */
  29. UNSPECIFIED,
  30. /**
  31. * The operation was unsupported.
  32. */
  33. UNSUPPORTED_OPERATION,
  34. /**
  35. * The operation was invalid.
  36. */
  37. INVALID_OPERATION,
  38. /**
  39. * The plugin manifest contains errors.
  40. */
  41. MANIFEST_ERROR,
  42. /**
  43. * The plugin was not resolved.
  44. */
  45. RESOLVE_ERROR,
  46. /**
  47. * The plugin activator was in error.
  48. */
  49. ACTIVATOR_ERROR,
  50. /**
  51. * The operation failed due to insufficient permissions.
  52. */
  53. SECURITY_ERROR,
  54. /**
  55. * The operation failed to complete the requested lifecycle state change.
  56. */
  57. STATECHANGE_ERROR,
  58. /**
  59. * The install or update operation failed because another
  60. * already installed plugin has the same symbolic name and version.
  61. */
  62. DUPLICATE_BUNDLE_ERROR
  63. };
  64. PluginException(const QString& msg, const Type& type = UNSPECIFIED, const std::exception& cause = std::exception());
  65. PluginException(const QString& msg, const std::exception& cause);
  66. PluginException(const PluginException& o);
  67. PluginException& operator=(const PluginException& o);
  68. ~PluginException() throw() {}
  69. std::exception getCause() const;
  70. void setCause(const std::exception&) throw(std::logic_error);
  71. Type getType() const;
  72. private:
  73. Type type;
  74. std::exception cause;
  75. };
  76. }
  77. CTK_CORE_EXPORT QDebug operator<<(QDebug dbg, const ctk::PluginException& exc);
  78. #endif // CTKPLUGINEXCEPTION_H