HDF5 C++ API  1.8.18
 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 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 namespace H5 {
23 #ifdef H5_NO_STD
24  #define H5std_string ::string
25 #else
26  #define H5std_string std::string
27 #endif
28 
34 class H5_DLLCPP Exception {
35  public:
36  // Creates an exception with a function name where the failure occurs
37  // and an optional detailed message
38  Exception(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
39 
40  // Returns a character string that describes the error specified by
41  // a major error number.
42  H5std_string getMajorString( hid_t err_major_id ) const;
43 
44  // Returns a character string that describes the error specified by
45  // a minor error number.
46  H5std_string getMinorString( hid_t err_minor_id ) const;
47 
48  // Returns the detailed message set at the time the exception is thrown
49  H5std_string getDetailMsg() const;
50  const char* getCDetailMsg() const; // C string of detailed message
51  H5std_string getFuncName() const; // function name as a string object
52  const char* getCFuncName() const; // function name as a char string
53 
54  // Turns on the automatic error printing.
55  static void setAutoPrint( H5E_auto2_t& func, void* client_data);
56 
57  // Turns off the automatic error printing.
58  static void dontPrint();
59 
60  // Retrieves the current settings for the automatic error stack
61  // traversal function and its data.
62  static void getAutoPrint( H5E_auto2_t& func, void** client_data);
63 
64  // Clears the error stack for the current thread.
65  static void clearErrorStack();
66 
67  // Walks the error stack for the current thread, calling the
68  // specified function.
69  static void walkErrorStack( H5E_direction_t direction,
70  H5E_walk2_t func, void* client_data);
71 
72  // Prints the error stack in a default manner.
73  static void printErrorStack(FILE* stream = stderr,
74  hid_t err_stack = H5E_DEFAULT); // Static
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 PropListIException : public Exception {
124  public:
125  PropListIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
127  virtual ~PropListIException() throw();
128 };
129 
130 class H5_DLLCPP DataSetIException : public Exception {
131  public:
132  DataSetIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
134  virtual ~DataSetIException() throw();
135 };
136 
137 class H5_DLLCPP AttributeIException : public Exception {
138  public:
139  AttributeIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
141  virtual ~AttributeIException() throw();
142 };
143 
144 class H5_DLLCPP ReferenceException : public Exception {
145  public:
146  ReferenceException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
148  virtual ~ReferenceException() throw();
149 };
150 
151 class H5_DLLCPP LibraryIException : public Exception {
152  public:
153  LibraryIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
155  virtual ~LibraryIException() throw();
156 };
157 
158 class H5_DLLCPP LocationException : public Exception {
159  public:
160  LocationException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
162  virtual ~LocationException() throw();
163 };
164 
165 class H5_DLLCPP IdComponentException : public Exception {
166  public:
167  IdComponentException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
169  virtual ~IdComponentException() throw();
170 };
171 }
172 
173 #endif // __H5Exception_H
Definition: H5Exception.h:116
Definition: H5Exception.h:130
Definition: H5Exception.h:109
Definition: H5Exception.h:102
Definition: H5Exception.h:137
Exception provides wrappers of HDF5 error handling functions.
Definition: H5Exception.h:34
Definition: H5Exception.h:123
Definition: H5Exception.h:95
Definition: H5Exception.h:144
Definition: H5Exception.h:158
Definition: H5Exception.h:165
Definition: H5Exception.h:151


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