ctkPluginException.h 4.2 KB

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