ctkServiceException.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 CTKSERVICEEXCEPTION_H
  16. #define CTKSERVICEEXCEPTION_H
  17. #include <stdexcept>
  18. #include <QString>
  19. #include "CTKPluginFrameworkExport.h"
  20. class CTK_PLUGINFW_EXPORT ctkServiceException : public std::runtime_error
  21. {
  22. public:
  23. enum Type {
  24. /**
  25. * No exception type is unspecified.
  26. */
  27. UNSPECIFIED = 0,
  28. /**
  29. * The service has been unregistered.
  30. */
  31. UNREGISTERED = 1,
  32. /**
  33. * The service factory produced an invalid service object.
  34. */
  35. FACTORY_ERROR = 2,
  36. /**
  37. * The service factory threw an exception.
  38. */
  39. FACTORY_EXCEPTION = 3,
  40. /**
  41. * The exception is a subclass of ctkServiceException. The subclass should be
  42. * examined for the type of the exception.
  43. */
  44. SUBCLASSED = 4,
  45. /**
  46. * An error occurred invoking a remote service.
  47. */
  48. REMOTE = 5
  49. };
  50. ctkServiceException(const QString& msg, const Type& type = UNSPECIFIED, const std::exception& cause = std::exception());
  51. ctkServiceException(const QString& msg, const std::exception& cause);
  52. ctkServiceException(const ctkServiceException& o);
  53. ctkServiceException& operator=(const ctkServiceException& o);
  54. ~ctkServiceException() throw() {}
  55. std::exception getCause() const;
  56. void setCause(const std::exception&) throw(std::logic_error);
  57. Type getType() const;
  58. private:
  59. Type type;
  60. std::exception cause;
  61. };
  62. CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug dbg, const ctkServiceException& exc);
  63. #endif // CTKSERVICEEXCEPTION_H