H5Exception.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // C++ informative line for the emacs editor: -*- C++ -*-
  2. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  3. * Copyright by The HDF Group. *
  4. * Copyright by the Board of Trustees of the University of Illinois. *
  5. * All rights reserved. *
  6. * *
  7. * This file is part of HDF5. The full HDF5 copyright notice, including *
  8. * terms governing use, modification, and redistribution, is contained in *
  9. * the COPYING file, which can be found at the root of the source code *
  10. * distribution tree, or in https://www.hdfgroup.org/licenses. *
  11. * If you do not have access to either file, you may request a copy from *
  12. * help@hdfgroup.org. *
  13. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  14. #ifndef H5Exception_H
  15. #define H5Exception_H
  16. #include <string>
  17. namespace H5 {
  18. #define H5std_string std::string
  19. /*! \class Exception
  20. \brief Exception provides wrappers of HDF5 error handling functions.
  21. Many classes are derived from Exception for specific HDF5 C interfaces.
  22. */
  23. class H5_DLLCPP Exception {
  24. public:
  25. // Creates an exception with a function name where the failure occurs
  26. // and an optional detailed message
  27. Exception(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  28. // Returns a character string that describes the error specified by
  29. // a major error number.
  30. H5std_string getMajorString(hid_t err_major_id) const;
  31. // Returns a character string that describes the error specified by
  32. // a minor error number.
  33. H5std_string getMinorString(hid_t err_minor_id) const;
  34. // Returns the detailed message set at the time the exception is thrown
  35. H5std_string getDetailMsg() const;
  36. const char * getCDetailMsg() const; // C string of detailed message
  37. H5std_string getFuncName() const; // function name as a string object
  38. const char * getCFuncName() const; // function name as a char string
  39. // Turns on the automatic error printing.
  40. static void setAutoPrint(H5E_auto2_t &func, void *client_data);
  41. // Turns off the automatic error printing.
  42. static void dontPrint();
  43. // Retrieves the current settings for the automatic error stack
  44. // traversal function and its data.
  45. static void getAutoPrint(H5E_auto2_t &func, void **client_data);
  46. // Clears the error stack for the current thread.
  47. static void clearErrorStack();
  48. // Walks the error stack for the current thread, calling the
  49. // specified function.
  50. static void walkErrorStack(H5E_direction_t direction, H5E_walk2_t func, void *client_data);
  51. // Prints the error stack in a default manner.
  52. static void printErrorStack(FILE *stream = stderr, hid_t err_stack = H5E_DEFAULT);
  53. // Deprecated in favor of printErrorStack.
  54. // Removed from code. -BMR, 2017/08/11 1.8.20 and 1.10.2
  55. // virtual void printError(FILE* stream = NULL) const;
  56. // Default constructor
  57. Exception();
  58. // copy constructor
  59. Exception(const Exception &orig);
  60. // virtual Destructor
  61. virtual ~Exception() throw();
  62. protected:
  63. // Default value for detail_message
  64. static const char DEFAULT_MSG[];
  65. private:
  66. H5std_string detail_message;
  67. H5std_string func_name;
  68. };
  69. class H5_DLLCPP FileIException : public Exception {
  70. public:
  71. FileIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  72. FileIException();
  73. virtual ~FileIException() throw() override;
  74. };
  75. class H5_DLLCPP GroupIException : public Exception {
  76. public:
  77. GroupIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  78. GroupIException();
  79. virtual ~GroupIException() throw() override;
  80. };
  81. class H5_DLLCPP DataSpaceIException : public Exception {
  82. public:
  83. DataSpaceIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  84. DataSpaceIException();
  85. virtual ~DataSpaceIException() throw() override;
  86. };
  87. class H5_DLLCPP DataTypeIException : public Exception {
  88. public:
  89. DataTypeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  90. DataTypeIException();
  91. virtual ~DataTypeIException() throw() override;
  92. };
  93. class H5_DLLCPP ObjHeaderIException : public Exception {
  94. public:
  95. ObjHeaderIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  96. ObjHeaderIException();
  97. virtual ~ObjHeaderIException() throw() override;
  98. };
  99. class H5_DLLCPP PropListIException : public Exception {
  100. public:
  101. PropListIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  102. PropListIException();
  103. virtual ~PropListIException() throw() override;
  104. };
  105. class H5_DLLCPP DataSetIException : public Exception {
  106. public:
  107. DataSetIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  108. DataSetIException();
  109. virtual ~DataSetIException() throw() override;
  110. };
  111. class H5_DLLCPP AttributeIException : public Exception {
  112. public:
  113. AttributeIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  114. AttributeIException();
  115. virtual ~AttributeIException() throw() override;
  116. };
  117. class H5_DLLCPP ReferenceException : public Exception {
  118. public:
  119. ReferenceException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  120. ReferenceException();
  121. virtual ~ReferenceException() throw() override;
  122. };
  123. class H5_DLLCPP LibraryIException : public Exception {
  124. public:
  125. LibraryIException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  126. LibraryIException();
  127. virtual ~LibraryIException() throw() override;
  128. };
  129. class H5_DLLCPP LocationException : public Exception {
  130. public:
  131. LocationException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  132. LocationException();
  133. virtual ~LocationException() throw() override;
  134. };
  135. class H5_DLLCPP IdComponentException : public Exception {
  136. public:
  137. IdComponentException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
  138. IdComponentException();
  139. virtual ~IdComponentException() throw() override;
  140. }; // end of IdComponentException
  141. } // namespace H5
  142. #endif // H5Exception_H