ctkApplicationException.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 CTKAPPLICATIONEXCEPTION_H
  16. #define CTKAPPLICATIONEXCEPTION_H
  17. #include <ctkPluginFrameworkExport.h>
  18. #include <ctkException.h>
  19. /**
  20. * This exception is used to indicate problems related to application lifecycle
  21. * management.
  22. *
  23. * <code>ctkApplicationException</code> object is created by the Application Admin
  24. * to denote an exception condition in the lifecycle of an application.
  25. * <code>ctkApplicationException</code>s should not be created by developers. <br/>
  26. * <code>ctkApplicationException</code>s are associated with an error code. This
  27. * code describes the type of problem reported in this exception. The possible
  28. * codes are:
  29. * <ul>
  30. * <li> APPLICATION_LOCKED - The application couldn't be launched
  31. * because it is locked.</li>
  32. * <li> APPLICATION_NOT_LAUNCHABLE - The application is not in
  33. * launchable state.</li>
  34. * <li> APPLICATION_INTERNAL_ERROR - An exception was thrown by the
  35. * application or its container during launch.</li>
  36. * <li> APPLICATION_SCHEDULING_FAILED - The scheduling of an application
  37. * failed.
  38. * <li> APPLICATION_DUPLICATE_SCHEDULE_ID - The application scheduling
  39. * failed because the specified identifier is already in use.
  40. * <li> APPLICATION_EXITVALUE_NOT_AVAILABLE - The exit value is not
  41. * available for an application instance because the instance has not
  42. * terminated.
  43. * <li> APPLICATION_INVALID_STARTUP_ARGUMENT - One of the specified
  44. * startup arguments is invalid, for example its type is not permitted.
  45. * </ul>
  46. */
  47. class CTK_PLUGINFW_EXPORT ctkApplicationException : public ctkException
  48. {
  49. private:
  50. int errorCode;
  51. public:
  52. /**
  53. * The application couldn't be launched because it is locked.
  54. */
  55. static const int APPLICATION_LOCKED; // = 0x01;
  56. /**
  57. * The application is not in launchable state, it's
  58. * {@link ApplicationDescriptor#APPLICATION_LAUNCHABLE}
  59. * attribute is false.
  60. */
  61. static const int APPLICATION_NOT_LAUNCHABLE; // = 0x02;
  62. /**
  63. * An exception was thrown by the application or the corresponding container
  64. * during launch. The exception is available from <code>getCause()</code>.
  65. */
  66. static const int APPLICATION_INTERNAL_ERROR; // = 0x03;
  67. /**
  68. * The application schedule could not be created due to some internal error
  69. * (for example, the schedule information couldn't be saved due to some
  70. * storage error).
  71. */
  72. static const int APPLICATION_SCHEDULING_FAILED; // = 0x04;
  73. /**
  74. * The application scheduling failed because the specified identifier
  75. * is already in use.
  76. */
  77. static const int APPLICATION_DUPLICATE_SCHEDULE_ID; // = 0x05;
  78. /**
  79. * The exit value is not available for an application instance because the
  80. * instance has not terminated.
  81. */
  82. static const int APPLICATION_EXITVALUE_NOT_AVAILABLE; // = 0x06;
  83. /**
  84. * One of the specified startup arguments is invalid, for example its
  85. * type is not permitted.
  86. */
  87. static const int APPLICATION_INVALID_STARTUP_ARGUMENT; // = 0x07;
  88. /**
  89. * Creates an <code>ApplicationException</code> with the specified error code.
  90. * @param errorCode The code of the error
  91. */
  92. ctkApplicationException(int errorCode);
  93. /**
  94. * Creates a <code>ApplicationException</code> that wraps another exception.
  95. *
  96. * @param errorCode The code of the error
  97. * @param cause The cause of this exception.
  98. */
  99. ctkApplicationException(int errorCode, const ctkException& cause);
  100. /**
  101. * Creates an <code>ApplicationException</code> with the specified error code.
  102. * @param errorCode The code of the error
  103. * @param message The associated message
  104. */
  105. ctkApplicationException(int errorCode, const QString& message);
  106. /**
  107. * Creates a <code>ApplicationException</code> that wraps another exception.
  108. *
  109. * @param errorCode The code of the error
  110. * @param message The associated message.
  111. * @param cause The cause of this exception.
  112. */
  113. ctkApplicationException(int errorCode, const QString& message, const ctkException& cause);
  114. ~ctkApplicationException() throw();
  115. const char* name() const throw();
  116. ctkApplicationException* clone() const;
  117. void rethrow() const;
  118. /**
  119. * Returns the error code associated with this exception.
  120. *
  121. * @return The error code of this exception.
  122. */
  123. int GetErrorCode() const;
  124. };
  125. #endif // CTKAPPLICATIONEXCEPTION_H