ctkPluginException.h 3.7 KB

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