ctkPluginException.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 <stdexcept>
  18. #include <QString>
  19. #include <QDebug>
  20. #include "CTKPluginFrameworkExport.h"
  21. class CTK_PLUGINFW_EXPORT ctkPluginException : public std::runtime_error
  22. {
  23. public:
  24. enum Type {
  25. /**
  26. * No exception type is unspecified.
  27. */
  28. UNSPECIFIED,
  29. /**
  30. * The operation was unsupported.
  31. */
  32. UNSUPPORTED_OPERATION,
  33. /**
  34. * The operation was invalid.
  35. */
  36. INVALID_OPERATION,
  37. /**
  38. * The plugin manifest contains errors.
  39. */
  40. MANIFEST_ERROR,
  41. /**
  42. * The plugin was not resolved.
  43. */
  44. RESOLVE_ERROR,
  45. /**
  46. * The plugin activator was in error.
  47. */
  48. ACTIVATOR_ERROR,
  49. /**
  50. * The operation failed due to insufficient permissions.
  51. */
  52. SECURITY_ERROR,
  53. /**
  54. * The operation failed to complete the requested lifecycle state change.
  55. */
  56. STATECHANGE_ERROR,
  57. /**
  58. * The install or update operation failed because another
  59. * already installed plugin has the same symbolic name and version.
  60. */
  61. DUPLICATE_BUNDLE_ERROR
  62. };
  63. ctkPluginException(const QString& msg, const Type& type = UNSPECIFIED, const std::exception& cause = std::exception());
  64. ctkPluginException(const QString& msg, const std::exception& cause);
  65. ctkPluginException(const ctkPluginException& o);
  66. ctkPluginException& operator=(const ctkPluginException& o);
  67. ~ctkPluginException() throw() {}
  68. std::exception getCause() const;
  69. void setCause(const std::exception&) throw(std::logic_error);
  70. Type getType() const;
  71. const char* what() const throw();
  72. private:
  73. Type type;
  74. std::exception cause;
  75. };
  76. CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug dbg, const ctkPluginException& exc);
  77. #endif // CTKPLUGINEXCEPTION_H