Field3D
Exception.h
Go to the documentation of this file.
00001 //----------------------------------------------------------------------------//
00002 
00003 /*
00004  * Copyright (c) 2009 Sony Pictures Imageworks Inc
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * Redistributions of source code must retain the above copyright
00013  * notice, this list of conditions and the following disclaimer.
00014  * Redistributions in binary form must reproduce the above copyright
00015  * notice, this list of conditions and the following disclaimer in the
00016  * documentation and/or other materials provided with the
00017  * distribution.  Neither the name of Sony Pictures Imageworks nor the
00018  * names of its contributors may be used to endorse or promote
00019  * products derived from this software without specific prior written
00020  * permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
00026  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00028  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00029  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00031  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00033  * OF THE POSSIBILITY OF SUCH DAMAGE.
00034  */
00035 
00036 //----------------------------------------------------------------------------//
00037 
00042 //----------------------------------------------------------------------------//
00043 
00044 #ifndef _INCLUDED_Field3D_Exception_H_
00045 #define _INCLUDED_Field3D_Exception_H_
00046 
00047 #include <stdexcept>
00048 
00049 //----------------------------------------------------------------------------//
00050 
00051 #include "ns.h"
00052 
00053 FIELD3D_NAMESPACE_OPEN
00054 
00057 namespace Exc {
00058 
00059 //----------------------------------------------------------------------------//
00060 // Exception
00061 //----------------------------------------------------------------------------//
00062 
00071 //----------------------------------------------------------------------------//
00072 
00073 class Exception : public std::exception
00074 {
00075  public:
00076 
00077   // Ctor, dtor ----------------------------------------------------------------
00078 
00080   Exception(const std::string &what) throw()
00081     : std::exception(), m_what(what)
00082   { }
00083 
00085   virtual ~Exception() throw()
00086     { }
00087 
00088   // std::exception ------------------------------------------------------------
00089 
00090   virtual const char* what() const throw()
00091     { return m_what.c_str(); }
00092 
00093  protected:
00094 
00095   // Data members --------------------------------------------------------------
00096 
00098   std::string m_what;
00099 
00100 };
00101 
00102 //----------------------------------------------------------------------------//
00103 // Exceptions used in Field3D
00104 //----------------------------------------------------------------------------//
00105 
00107 #define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class) \
00108 class name : public base_class \
00109 { \
00110  public: \
00111   explicit name(const std::string &what = "") throw() \
00112     : base_class(what) \
00113   { } \
00114   ~name() throw() \
00115   { } \
00116 }; \
00117 
00118 //----------------------------------------------------------------------------//
00119 
00120 DECLARE_FIELD3D_GENERIC_EXCEPTION(AttrGetNativeTypeException, Exception)
00121 DECLARE_FIELD3D_GENERIC_EXCEPTION(AttrGetSpaceException, Exception)
00122 DECLARE_FIELD3D_GENERIC_EXCEPTION(AttrGetTypeException, Exception)
00123 DECLARE_FIELD3D_GENERIC_EXCEPTION(BadFileHierarchyException, Exception)
00124 DECLARE_FIELD3D_GENERIC_EXCEPTION(BadHdf5IdException, Exception)
00125 DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateDataSetException, Exception)
00126 DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateDataSpaceException, Exception)
00127 DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateDataTypeException, Exception)
00128 DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateGroupException, Exception)
00129 DECLARE_FIELD3D_GENERIC_EXCEPTION(ErrorCreatingFileException, Exception)
00130 DECLARE_FIELD3D_GENERIC_EXCEPTION(FileIntegrityException, Exception)
00131 DECLARE_FIELD3D_GENERIC_EXCEPTION(GetDataSpaceException, Exception)
00132 DECLARE_FIELD3D_GENERIC_EXCEPTION(GetDataTypeException, Exception)
00133 DECLARE_FIELD3D_GENERIC_EXCEPTION(Hdf5DataReadException, Exception)
00134 DECLARE_FIELD3D_GENERIC_EXCEPTION(MissingAttributeException, Exception)
00135 DECLARE_FIELD3D_GENERIC_EXCEPTION(MissingGroupException, Exception)
00136 DECLARE_FIELD3D_GENERIC_EXCEPTION(NoSuchFileException, Exception)
00137 DECLARE_FIELD3D_GENERIC_EXCEPTION(OpenDataSetException, Exception)
00138 DECLARE_FIELD3D_GENERIC_EXCEPTION(ReadHyperSlabException, Exception)
00139 DECLARE_FIELD3D_GENERIC_EXCEPTION(ReadMappingException, Exception)
00140 DECLARE_FIELD3D_GENERIC_EXCEPTION(UnsupportedVersionException, Exception)
00141 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteAttributeException, Exception)
00142 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteHyperSlabException, Exception)
00143 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteLayerException, Exception)
00144 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteMACFieldDataException, Exception)
00145 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteMappingException, Exception)
00146 DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteSimpleDataException, Exception)
00147 
00148 //----------------------------------------------------------------------------//
00149 
00150 } // namespace Exc
00151 
00152 FIELD3D_NAMESPACE_HEADER_CLOSE
00153 
00154 //----------------------------------------------------------------------------//
00155 
00156 #endif // Include guard