Field3D
Exception.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------//
2 
3 /*
4  * Copyright (c) 2009 Sony Pictures Imageworks Inc
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution. Neither the name of Sony Pictures Imageworks nor the
18  * names of its contributors may be used to endorse or promote
19  * products derived from this software without specific prior written
20  * permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33  * OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 //----------------------------------------------------------------------------//
37 
42 //----------------------------------------------------------------------------//
43 
44 #ifndef _INCLUDED_Field3D_Exception_H_
45 #define _INCLUDED_Field3D_Exception_H_
46 
47 #include <stdexcept>
48 
49 //----------------------------------------------------------------------------//
50 
51 #include "ns.h"
52 
54 
57 namespace Exc {
58 
59 //----------------------------------------------------------------------------//
60 // Exception
61 //----------------------------------------------------------------------------//
62 
71 //----------------------------------------------------------------------------//
72 
73 class Exception : public std::exception
74 {
75  public:
76 
77  // Ctor, dtor ----------------------------------------------------------------
78 
80  Exception(const std::string &what) throw()
81  : std::exception(), m_what(what)
82  { }
83 
85  virtual ~Exception() throw()
86  { }
87 
88  // std::exception ------------------------------------------------------------
89 
90  virtual const char* what() const throw()
91  { return m_what.c_str(); }
92 
93  protected:
94 
95  // Data members --------------------------------------------------------------
96 
98  std::string m_what;
99 
100 };
101 
102 //----------------------------------------------------------------------------//
103 // Exceptions used in Field3D
104 //----------------------------------------------------------------------------//
105 
107 #define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class) \
108 class name : public base_class \
109 { \
110  public: \
111  explicit name(const std::string &what = "") throw() \
112  : base_class(what) \
113  { } \
114  ~name() throw() \
115  { } \
116 }; \
117 
118 //----------------------------------------------------------------------------//
119 
120 DECLARE_FIELD3D_GENERIC_EXCEPTION(AttrGetNativeTypeException, Exception)
121 DECLARE_FIELD3D_GENERIC_EXCEPTION(AttrGetSpaceException, Exception)
122 DECLARE_FIELD3D_GENERIC_EXCEPTION(AttrGetTypeException, Exception)
123 DECLARE_FIELD3D_GENERIC_EXCEPTION(BadFileHierarchyException, Exception)
124 DECLARE_FIELD3D_GENERIC_EXCEPTION(BadHdf5IdException, Exception)
125 DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateDataSetException, Exception)
126 DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateDataSpaceException, Exception)
127 DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateDataTypeException, Exception)
128 DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateGroupException, Exception)
129 DECLARE_FIELD3D_GENERIC_EXCEPTION(ErrorCreatingFileException, Exception)
130 DECLARE_FIELD3D_GENERIC_EXCEPTION(FileIntegrityException, Exception)
131 DECLARE_FIELD3D_GENERIC_EXCEPTION(GetDataSpaceException, Exception)
132 DECLARE_FIELD3D_GENERIC_EXCEPTION(GetDataTypeException, Exception)
133 DECLARE_FIELD3D_GENERIC_EXCEPTION(Hdf5DataReadException, Exception)
134 DECLARE_FIELD3D_GENERIC_EXCEPTION(MissingAttributeException, Exception)
135 DECLARE_FIELD3D_GENERIC_EXCEPTION(MissingGroupException, Exception)
136 DECLARE_FIELD3D_GENERIC_EXCEPTION(NoSuchFileException, Exception)
137 DECLARE_FIELD3D_GENERIC_EXCEPTION(OpenDataSetException, Exception)
138 DECLARE_FIELD3D_GENERIC_EXCEPTION(ReadHyperSlabException, Exception)
139 DECLARE_FIELD3D_GENERIC_EXCEPTION(ReadMappingException, Exception)
140 DECLARE_FIELD3D_GENERIC_EXCEPTION(UnsupportedVersionException, Exception)
141 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteAttributeException, Exception)
142 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteHyperSlabException, Exception)
143 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteLayerException, Exception)
144 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteMACFieldDataException, Exception)
145 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteMappingException, Exception)
146 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteSimpleDataException, Exception)
147 
148 DECLARE_FIELD3D_GENERIC_EXCEPTION(OgIGroupException, Exception)
149 DECLARE_FIELD3D_GENERIC_EXCEPTION(OgIDatasetException, Exception)
150 DECLARE_FIELD3D_GENERIC_EXCEPTION(OgIAttributeException, Exception)
151 DECLARE_FIELD3D_GENERIC_EXCEPTION(OgOGroupException, Exception)
152 DECLARE_FIELD3D_GENERIC_EXCEPTION(OgODatasetException, Exception)
153 DECLARE_FIELD3D_GENERIC_EXCEPTION(OgOAttributeException, Exception)
154 
155 DECLARE_FIELD3D_GENERIC_EXCEPTION(ReadDataException, Exception)
156 
157 //----------------------------------------------------------------------------//
158 
159 } // namespace Exc
160 
162 
163 //----------------------------------------------------------------------------//
164 
165 #endif // Include guard
FIELD3D_NAMESPACE_HEADER_CLOSE
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58
Exc::Exception::what
virtual const char * what() const
Definition: Exception.h:90
Exc::Exception::Exception
Exception(const std::string &what)
Construct from string.
Definition: Exception.h:80
Exc::Exception::~Exception
virtual ~Exception()
Destructor.
Definition: Exception.h:85
ns.h
Exc::Exception
Definition: Exception.h:73
Exc::Exception::m_what
std::string m_what
What string for the expection.
Definition: Exception.h:98
Exc
Namespace for Exception objects.
Definition: Exception.h:57
FIELD3D_NAMESPACE_OPEN
Definition: FieldMapping.cpp:74
DECLARE_FIELD3D_GENERIC_EXCEPTION
#define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class)
Used to declare a generic but named exception.
Definition: Exception.h:107