HDF5 C++ API  1.8.20
 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 
22 #ifdef H5_NO_STD
23  #define H5std_string ::string
24 #else
25  #define H5std_string std::string
26 #endif
27 
33 class H5_DLLCPP Exception {
34  public:
35  // Creates an exception with a function name where the failure occurs
36  // and an optional detailed message
37  Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
38 
39  // Returns a character string that describes the error specified by
40  // a major error number.
41  H5std_string getMajorString(hid_t err_major_id) const;
42 
43  // Returns a character string that describes the error specified by
44  // a minor error number.
45  H5std_string getMinorString(hid_t err_minor_id) const;
46 
47  // Returns the detailed message set at the time the exception is thrown
48  H5std_string getDetailMsg() const;
49  const char* getCDetailMsg() const; // C string of detailed message
50  H5std_string getFuncName() const; // function name as a string object
51  const char* getCFuncName() const; // function name as a char string
52 
53  // Turns on the automatic error printing.
54  static void setAutoPrint(H5E_auto2_t& func, void* client_data);
55 
56  // Turns off the automatic error printing.
57  static void dontPrint();
58 
59  // Retrieves the current settings for the automatic error stack
60  // traversal function and its data.
61  static void getAutoPrint(H5E_auto2_t& func, void** client_data);
62 
63  // Clears the error stack for the current thread.
64  static void clearErrorStack();
65 
66  // Walks the error stack for the current thread, calling the
67  // specified function.
68  static void walkErrorStack(H5E_direction_t direction,
69  H5E_walk2_t func, void* client_data);
70 
71  // Prints the error stack in a default manner.
72  static void printErrorStack(FILE* stream = stderr,
73  hid_t err_stack = H5E_DEFAULT); // Static
74  virtual void printError(FILE* stream = NULL) const;
75 
76  // Default constructor
77  Exception();
78 
79  // copy constructor
80  Exception(const Exception& orig);
81 
82  // virtual Destructor
83  virtual ~Exception() throw();
84 
85  protected:
86  // Default value for detail_message
87  static const char DEFAULT_MSG[];
88 
89  private:
90  H5std_string detail_message;
91  H5std_string func_name;
92 };
93 
94 class H5_DLLCPP FileIException : public Exception {
95  public:
96  FileIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
98  virtual ~FileIException() throw();
99 };
100 
101 class H5_DLLCPP GroupIException : public Exception {
102  public:
103  GroupIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
104  GroupIException();
105  virtual ~GroupIException() throw();
106 };
107 
108 class H5_DLLCPP DataSpaceIException : public Exception {
109  public:
110  DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
112  virtual ~DataSpaceIException() throw();
113 };
114 
115 class H5_DLLCPP DataTypeIException : public Exception {
116  public:
117  DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
119  virtual ~DataTypeIException() throw();
120 };
121 
122 class H5_DLLCPP PropListIException : public Exception {
123  public:
124  PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
126  virtual ~PropListIException() throw();
127 };
128 
129 class H5_DLLCPP DataSetIException : public Exception {
130  public:
131  DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
133  virtual ~DataSetIException() throw();
134 };
135 
136 class H5_DLLCPP AttributeIException : public Exception {
137  public:
138  AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
140  virtual ~AttributeIException() throw();
141 };
142 
143 class H5_DLLCPP ReferenceException : public Exception {
144  public:
145  ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
147  virtual ~ReferenceException() throw();
148 };
149 
150 class H5_DLLCPP LibraryIException : public Exception {
151  public:
152  LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
154  virtual ~LibraryIException() throw();
155 };
156 
157 class H5_DLLCPP LocationException : public Exception {
158  public:
159  LocationException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
161  virtual ~LocationException() throw();
162 };
163 
164 class H5_DLLCPP IdComponentException : public Exception {
165  public:
166  IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
168  virtual ~IdComponentException() throw();
169 
170 }; // end of IdComponentException
171 } // namespace H5
172 
173 #endif // __H5Exception_H
Definition: H5Exception.h:115
Definition: H5Exception.h:129
Definition: H5Exception.h:108
Definition: H5Exception.h:101
Definition: H5Exception.h:136
Exception provides wrappers of HDF5 error handling functions.
Definition: H5Exception.h:33
Definition: H5Exception.h:122
Definition: H5Exception.h:94
Definition: H5Exception.h:143
Definition: H5Exception.h:157
Definition: H5Exception.h:164
Definition: H5Exception.h:150


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