ctkPluginException.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 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 "ctkRuntimeException.h"
  18. /**
  19. * \ingroup PluginFramework
  20. *
  21. * A Plugin Framework exception used to indicate that a plugin lifecycle
  22. * problem occurred.
  23. *
  24. * <p>
  25. * A <code>ctkPluginException</code> object is created by the Framework to denote
  26. * an exception condition in the lifecycle of a plugin.
  27. * <code>ctkPluginException</code>s should not be created by plugin developers.
  28. * An enum type is used to identify the exception type for future extendability.
  29. *
  30. * <p>
  31. * This exception conforms to the general purpose exception chaining mechanism.
  32. */
  33. class CTK_PLUGINFW_EXPORT ctkPluginException : public ctkRuntimeException
  34. {
  35. public:
  36. enum Type {
  37. /**
  38. * No exception type is unspecified.
  39. */
  40. UNSPECIFIED,
  41. /**
  42. * The operation was unsupported.
  43. */
  44. UNSUPPORTED_OPERATION,
  45. /**
  46. * The operation was invalid.
  47. */
  48. INVALID_OPERATION,
  49. /**
  50. * The plugin manifest contains errors.
  51. */
  52. MANIFEST_ERROR,
  53. /**
  54. * The plugin was not resolved.
  55. */
  56. RESOLVE_ERROR,
  57. /**
  58. * The plugin activator was in error.
  59. */
  60. ACTIVATOR_ERROR,
  61. /**
  62. * The operation failed due to insufficient permissions.
  63. */
  64. SECURITY_ERROR,
  65. /**
  66. * The operation failed to complete the requested lifecycle state change.
  67. */
  68. STATECHANGE_ERROR,
  69. /**
  70. * The install or update operation failed because another
  71. * already installed plugin has the same symbolic name and version.
  72. */
  73. DUPLICATE_PLUGIN_ERROR,
  74. /**
  75. * The framework received an error while reading the input stream for a plugin.
  76. */
  77. READ_ERROR,
  78. /**
  79. * The start transient operation failed because the start level of the
  80. * plugin is greater than the current framework start level
  81. */
  82. START_TRANSIENT_ERROR
  83. };
  84. /**
  85. * Creates a <code>ctkPluginException</code> with the specified message, type
  86. * and exception cause.
  87. *
  88. * @param msg The associated message.
  89. * @param type The type for this exception.
  90. * @param cause The cause of this exception.
  91. */
  92. ctkPluginException(const QString& msg, const Type& type = UNSPECIFIED, const std::exception* cause = 0);
  93. /**
  94. * Creates a <code>ctkPluginException</code> with the specified message and
  95. * exception cause.
  96. *
  97. * @param msg The associated message.
  98. * @param cause The cause of this exception.
  99. */
  100. ctkPluginException(const QString& msg, const std::exception* cause);
  101. ctkPluginException(const ctkPluginException& o);
  102. ctkPluginException& operator=(const ctkPluginException& o);
  103. /**
  104. * Returns the type for this exception or <code>UNSPECIFIED</code> if the
  105. * type was unspecified or unknown.
  106. *
  107. * @return The type of this exception.
  108. */
  109. Type getType() const;
  110. private:
  111. /**
  112. * Type of plugin exception.
  113. */
  114. Type type;
  115. };
  116. /**
  117. * \ingroup PluginFramework
  118. */
  119. CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug dbg, const ctkPluginException& exc);
  120. #endif // CTKPLUGINEXCEPTION_H