ctkServiceException.h 3.5 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 CTKSERVICEEXCEPTION_H
  16. #define CTKSERVICEEXCEPTION_H
  17. #include "ctkException.h"
  18. #include <ctkPluginFrameworkExport.h>
  19. /**
  20. * \ingroup PluginFramework
  21. *
  22. * A service exception used to indicate that a service problem occurred.
  23. *
  24. * <p>
  25. * A <code>ctkServiceException</code> object is created by the Framework or
  26. * to denote an exception condition in the service. An enum
  27. * type is used to identify the exception type for future extendability.
  28. *
  29. * <p>
  30. * This exception conforms to the general purpose exception chaining mechanism.
  31. */
  32. class CTK_PLUGINFW_EXPORT ctkServiceException : public ctkRuntimeException
  33. {
  34. public:
  35. enum Type {
  36. /**
  37. * No exception type is unspecified.
  38. */
  39. UNSPECIFIED = 0,
  40. /**
  41. * The service has been unregistered.
  42. */
  43. UNREGISTERED = 1,
  44. /**
  45. * The service factory produced an invalid service object.
  46. */
  47. FACTORY_ERROR = 2,
  48. /**
  49. * The service factory threw an exception.
  50. */
  51. FACTORY_EXCEPTION = 3,
  52. /**
  53. * An error occurred invoking a remote service.
  54. */
  55. REMOTE = 5,
  56. /**
  57. * The service factory resulted in a recursive call to itself for the
  58. * requesting plugin.
  59. */
  60. FACTORY_RECURSION = 6
  61. };
  62. /**
  63. * Creates a <code>ctkServiceException</code> with the specified message and
  64. * type.
  65. *
  66. * @param msg The associated message.
  67. * @param type The type for this exception.
  68. */
  69. ctkServiceException(const QString& msg, const Type& type = UNSPECIFIED);
  70. /**
  71. * Creates a <code>ctkServiceException</code> with the specified message,
  72. * type and exception cause.
  73. *
  74. * @param msg The associated message.
  75. * @param type The type for this exception.
  76. * @param cause The cause of this exception.
  77. */
  78. ctkServiceException(const QString& msg, const Type& type, const ctkException& cause);
  79. /**
  80. * Creates a <code>ctkServiceException</code> with the specified message and
  81. * exception cause.
  82. *
  83. * @param msg The associated message.
  84. * @param cause The cause of this exception.
  85. */
  86. ctkServiceException(const QString& msg, const ctkException& cause);
  87. ctkServiceException(const ctkServiceException& o);
  88. ctkServiceException& operator=(const ctkServiceException& o);
  89. ~ctkServiceException() throw();
  90. /**
  91. * @see ctkException::name()
  92. */
  93. const char* name() const throw();
  94. /**
  95. * @see ctkException::clone()
  96. */
  97. ctkServiceException* clone() const;
  98. /**
  99. * Returns the type for this exception or <code>UNSPECIFIED</code> if the
  100. * type was unspecified or unknown.
  101. *
  102. * @return The type of this exception.
  103. */
  104. Type getType() const;
  105. private:
  106. /**
  107. * Type of service exception.
  108. */
  109. Type type;
  110. };
  111. #endif // CTKSERVICEEXCEPTION_H