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


The HDF Group Help Desk:
  Copyright by The HDF Group
and the Board of Trustees of the University of Illinois