HDF5 C++ API  1.8.12
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
H5Exception.h
Go to the documentation of this file.
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 // Class Exception has many subclasses of exceptions for various types of HDF5 APIs.
18 
19 #ifndef __H5Exception_H
20 #define __H5Exception_H
21 
22 #include <string>
23 
24 #ifndef H5_NO_NAMESPACE
25 namespace H5 {
26 #ifdef H5_NO_STD
27  #define H5std_string ::string
28 #else
29  #define H5std_string std::string
30 #endif
31 #endif
32 
38 class H5_DLLCPP Exception {
39  public:
40  // Creates an exception with a function name where the failure occurs
41  // and an optional detailed message
42  Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
43 
44  // Returns a character string that describes the error specified by
45  // a major error number.
46  H5std_string getMajorString( hid_t err_major_id ) const;
47 
48  // Returns a character string that describes the error specified by
49  // a minor error number.
50  H5std_string getMinorString( hid_t err_minor_id ) const;
51 
52  // Returns the detailed message set at the time the exception is thrown
53  H5std_string getDetailMsg() const;
54  const char* getCDetailMsg() const; // C string of detailed message
55  H5std_string getFuncName() const; // function name as a string object
56  const char* getCFuncName() const; // function name as a char string
57 
58  // Turns on the automatic error printing.
59  static void setAutoPrint( H5E_auto2_t& func, void* client_data);
60 
61  // Turns off the automatic error printing.
62  static void dontPrint();
63 
64  // Retrieves the current settings for the automatic error stack
65  // traversal function and its data.
66  static void getAutoPrint( H5E_auto2_t& func, void** client_data);
67 
68  // Clears the error stack for the current thread.
69  static void clearErrorStack();
70 
71  // Walks the error stack for the current thread, calling the
72  // specified function.
73  static void walkErrorStack( H5E_direction_t direction,
74  H5E_walk2_t func, void* client_data);
75 
76  // Prints the error stack in a default manner.
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();
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();
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();
109 };
110 
111 class H5_DLLCPP DataSpaceIException : public Exception {
112  public:
113  DataSpaceIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
115  virtual ~DataSpaceIException();
116 };
117 
118 class H5_DLLCPP DataTypeIException : public Exception {
119  public:
120  DataTypeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
122  virtual ~DataTypeIException();
123 };
124 
125 class H5_DLLCPP PropListIException : public Exception {
126  public:
127  PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
129  virtual ~PropListIException();
130 };
131 
132 class H5_DLLCPP DataSetIException : public Exception {
133  public:
134  DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
136  virtual ~DataSetIException();
137 };
138 
139 class H5_DLLCPP AttributeIException : public Exception {
140  public:
141  AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
143  virtual ~AttributeIException();
144 };
145 
146 class H5_DLLCPP ReferenceException : public Exception {
147  public:
148  ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
150  virtual ~ReferenceException();
151 };
152 
153 class H5_DLLCPP LibraryIException : public Exception {
154  public:
155  LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
157  virtual ~LibraryIException();
158 };
159 
160 class H5_DLLCPP IdComponentException : public Exception {
161  public:
162  IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
164  virtual ~IdComponentException();
165 };
166 
167 #ifndef H5_NO_NAMESPACE
168 }
169 #endif
170 
171 #endif // __H5Exception_H
Definition: H5Exception.h:139
Exception provides wrappers of HDF5 error handling functions.
Definition: H5Exception.h:38
Definition: H5Exception.h:160
Definition: H5Exception.h:146
Definition: H5Exception.h:111
Definition: H5Exception.h:125
Definition: H5Exception.h:153
Definition: H5Exception.h:97
#define H5std_string
Definition: H5Exception.h:29
Definition: H5Exception.h:104
Definition: H5Exception.h:132
Definition: H5Exception.h:118