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 files COPYING and Copyright.html. COPYING can be found at the root * 10 * of the source code distribution tree; Copyright.html can be found at the * 11 * root level of an installed copy of the electronic HDF5 document set and * 12 * is linked from the top-level documents page. It can also be found at * 13 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 14 * access to either file, you may request a copy from help@hdfgroup.org. * 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 16 17 #ifndef __H5Exception_H 18 #define __H5Exception_H 19 20 #include <string> 21 22 #ifndef H5_NO_NAMESPACE 23 namespace H5 { 24 #ifdef H5_NO_STD 25 #define H5std_string ::string 26 #else 27 #define H5std_string std::string 28 #endif 29 #endif 30 31 /*! \class Exception 32 \brief Exception provides wrappers of HDF5 error handling functions. 33 34 Many classes are derived from Exception for specific HDF5 C interfaces. 35 */ 36 class H5_DLLCPP Exception { 37 public: 38 // Creates an exception with a function name where the failure occurs 39 // and an optional detailed message 40 Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 41 42 // Returns a character string that describes the error specified by 43 // a major error number. 44 H5std_string getMajorString( hid_t err_major_id ) const; 45 46 // Returns a character string that describes the error specified by 47 // a minor error number. 48 H5std_string getMinorString( hid_t err_minor_id ) const; 49 50 // Returns the detailed message set at the time the exception is thrown 51 H5std_string getDetailMsg() const; 52 const char* getCDetailMsg() const; // C string of detailed message 53 H5std_string getFuncName() const; // function name as a string object 54 const char* getCFuncName() const; // function name as a char string 55 56 // Turns on the automatic error printing. 57 static void setAutoPrint( H5E_auto2_t& func, void* client_data); 58 59 // Turns off the automatic error printing. 60 static void dontPrint(); 61 62 // Retrieves the current settings for the automatic error stack 63 // traversal function and its data. 64 static void getAutoPrint( H5E_auto2_t& func, void** client_data); 65 66 // Clears the error stack for the current thread. 67 static void clearErrorStack(); 68 69 // Walks the error stack for the current thread, calling the 70 // specified function. 71 static void walkErrorStack( H5E_direction_t direction, 72 H5E_walk2_t func, void* client_data); 73 74 // Prints the error stack in a default manner. 75 static void printErrorStack(FILE* stream = stderr, 76 hid_t err_stack = H5E_DEFAULT); // Static 77 virtual void printError(FILE* stream = NULL) const; 78 79 // Default constructor 80 Exception(); 81 82 // copy constructor 83 Exception( const Exception& orig); 84 85 // virtual Destructor 86 virtual ~Exception() throw(); 87 88 private: 89 H5std_string detail_message; 90 H5std_string func_name; 91 92 protected: 93 // Default value for detail_message 94 static const char DEFAULT_MSG[]; 95 }; 96 97 class H5_DLLCPP FileIException : public Exception { 98 public: 99 FileIException( const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 100 FileIException(); 101 virtual ~FileIException() throw(); 102 }; 103 104 class H5_DLLCPP GroupIException : public Exception { 105 public: 106 GroupIException( const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 107 GroupIException(); 108 virtual ~GroupIException() throw(); 109 }; 110 111 class H5_DLLCPP DataSpaceIException : public Exception { 112 public: 113 DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 114 DataSpaceIException(); 115 virtual ~DataSpaceIException() throw(); 116 }; 117 118 class H5_DLLCPP DataTypeIException : public Exception { 119 public: 120 DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 121 DataTypeIException(); 122 virtual ~DataTypeIException() throw(); 123 }; 124 125 class H5_DLLCPP PropListIException : public Exception { 126 public: 127 PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 128 PropListIException(); 129 virtual ~PropListIException() throw(); 130 }; 131 132 class H5_DLLCPP DataSetIException : public Exception { 133 public: 134 DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 135 DataSetIException(); 136 virtual ~DataSetIException() throw(); 137 }; 138 139 class H5_DLLCPP AttributeIException : public Exception { 140 public: 141 AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 142 AttributeIException(); 143 virtual ~AttributeIException() throw(); 144 }; 145 146 class H5_DLLCPP ReferenceException : public Exception { 147 public: 148 ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 149 ReferenceException(); 150 virtual ~ReferenceException() throw(); 151 }; 152 153 class H5_DLLCPP LibraryIException : public Exception { 154 public: 155 LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 156 LibraryIException(); 157 virtual ~LibraryIException() throw(); 158 }; 159 160 class H5_DLLCPP LocationException : public Exception { 161 public: 162 LocationException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 163 LocationException(); 164 virtual ~LocationException() throw(); 165 }; 166 167 class H5_DLLCPP IdComponentException : public Exception { 168 public: 169 IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG); 170 IdComponentException(); 171 virtual ~IdComponentException() throw(); 172 }; 173 174 #ifndef H5_NO_NAMESPACE 175 } 176 #endif 177 178 #endif // __H5Exception_H 179