HDF5 C++ API  1.10.1
 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  virtual void printError(FILE* stream = NULL) const;
74 
75  // Default constructor
76  Exception();
77 
78  // copy constructor
79  Exception(const Exception& orig);
80 
81  // virtual Destructor
82  virtual ~Exception() throw();
83 
84  protected:
85  // Default value for detail_message
86  static const char DEFAULT_MSG[];
87 
88  private:
89  H5std_string detail_message;
90  H5std_string func_name;
91 };
92 
93 class H5_DLLCPP FileIException : public Exception {
94  public:
95  FileIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
97  virtual ~FileIException() throw();
98 };
99 
100 class H5_DLLCPP GroupIException : public Exception {
101  public:
102  GroupIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
103  GroupIException();
104  virtual ~GroupIException() throw();
105 };
106 
107 class H5_DLLCPP DataSpaceIException : public Exception {
108  public:
109  DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
111  virtual ~DataSpaceIException() throw();
112 };
113 
114 class H5_DLLCPP DataTypeIException : public Exception {
115  public:
116  DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
118  virtual ~DataTypeIException() throw();
119 };
120 
121 class H5_DLLCPP ObjHeaderIException : public Exception {
122  public:
123  ObjHeaderIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
125  virtual ~ObjHeaderIException() throw();
126 };
127 
128 class H5_DLLCPP PropListIException : public Exception {
129  public:
130  PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
132  virtual ~PropListIException() throw();
133 };
134 
135 class H5_DLLCPP DataSetIException : public Exception {
136  public:
137  DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
139  virtual ~DataSetIException() throw();
140 };
141 
142 class H5_DLLCPP AttributeIException : public Exception {
143  public:
144  AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
146  virtual ~AttributeIException() throw();
147 };
148 
149 class H5_DLLCPP ReferenceException : public Exception {
150  public:
151  ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
153  virtual ~ReferenceException() throw();
154 };
155 
156 class H5_DLLCPP LibraryIException : public Exception {
157  public:
158  LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
160  virtual ~LibraryIException() throw();
161 };
162 
163 class H5_DLLCPP LocationException : public Exception {
164  public:
165  LocationException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
167  virtual ~LocationException() throw();
168 };
169 
170 class H5_DLLCPP IdComponentException : public Exception {
171  public:
172  IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
174  virtual ~IdComponentException() throw();
175 
176 }; // end of IdComponentException
177 } // namespace H5
178 
179 #endif // __H5Exception_H
Definition: H5Exception.h:114
Definition: H5Exception.h:135
Definition: H5Exception.h:107
Definition: H5Exception.h:100
Definition: H5Exception.h:142
Exception provides wrappers of HDF5 error handling functions.
Definition: H5Exception.h:32
Definition: H5Exception.h:128
Definition: H5Exception.h:93
Definition: H5Exception.h:149
Definition: H5Exception.h:163
Definition: H5Exception.h:121
Definition: H5Exception.h:170
Definition: H5Exception.h:156


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