Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:54:39

0001 /*
0002  *  Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
0003  *
0004  *  Distributed under the Boost Software License, Version 1.0.
0005  *    (See accompanying file LICENSE_1_0.txt or copy at
0006  *          http://www.boost.org/LICENSE_1_0.txt)
0007  *
0008  */
0009 #pragma once
0010 
0011 #include <memory>
0012 #include <stdexcept>
0013 #include <string>
0014 
0015 #include <H5Ipublic.h>
0016 
0017 namespace HighFive {
0018 
0019 ///
0020 /// \brief Basic HighFive Exception class
0021 ///
0022 ///
0023 class Exception: public std::exception {
0024   public:
0025     explicit Exception(const std::string& err_msg)
0026         : _errmsg(err_msg) {}
0027 
0028     Exception(const Exception& other) = default;
0029     Exception(Exception&& other) noexcept = default;
0030 
0031     Exception& operator=(const Exception& other) = default;
0032     Exception& operator=(Exception&& other) noexcept = default;
0033 
0034     ~Exception() noexcept override {}
0035 
0036     ///
0037     /// \brief get the current exception error message
0038     /// \return
0039     ///
0040     inline const char* what() const noexcept override {
0041         return _errmsg.c_str();
0042     }
0043 
0044     ///
0045     /// \brief define the error message
0046     /// \param errmsg
0047     ///
0048     inline virtual void setErrorMsg(const std::string& errmsg) {
0049         _errmsg = errmsg;
0050     }
0051 
0052     ///
0053     /// \brief nextException
0054     /// \return pointer to the next exception in the chain, or NULL if not
0055     /// existing
0056     ///
0057     inline Exception* nextException() const {
0058         return _next.get();
0059     }
0060 
0061     ///
0062     /// \brief HDF5 library error mapper
0063     /// \return HDF5 major error number
0064     ///
0065     inline hid_t getErrMajor() const {
0066         return _err_major;
0067     }
0068 
0069     ///
0070     /// \brief HDF5 library error mapper
0071     /// \return HDF5 minor error number
0072     ///
0073     inline hid_t getErrMinor() const {
0074         return _err_minor;
0075     }
0076 
0077   private:
0078     std::string _errmsg;
0079     std::shared_ptr<Exception> _next = nullptr;
0080     hid_t _err_major = 0, _err_minor = 0;
0081 
0082     friend struct HDF5ErrMapper;
0083 };
0084 
0085 ///
0086 /// \brief Exception specific to HighFive Object interface
0087 ///
0088 class ObjectException: public Exception {
0089   public:
0090     explicit ObjectException(const std::string& err_msg)
0091         : Exception(err_msg) {}
0092 };
0093 
0094 ///
0095 /// \brief Exception specific to HighFive DataType interface
0096 ///
0097 class DataTypeException: public Exception {
0098   public:
0099     explicit DataTypeException(const std::string& err_msg)
0100         : Exception(err_msg) {}
0101 };
0102 
0103 ///
0104 /// \brief Exception specific to HighFive File interface
0105 ///
0106 class FileException: public Exception {
0107   public:
0108     explicit FileException(const std::string& err_msg)
0109         : Exception(err_msg) {}
0110 };
0111 
0112 ///
0113 /// \brief Exception specific to HighFive DataSpace interface
0114 ///
0115 class DataSpaceException: public Exception {
0116   public:
0117     explicit DataSpaceException(const std::string& err_msg)
0118         : Exception(err_msg) {}
0119 };
0120 
0121 ///
0122 /// \brief Exception specific to HighFive Attribute interface
0123 ///
0124 class AttributeException: public Exception {
0125   public:
0126     explicit AttributeException(const std::string& err_msg)
0127         : Exception(err_msg) {}
0128 };
0129 
0130 ///
0131 /// \brief Exception specific to HighFive DataSet interface
0132 ///
0133 class DataSetException: public Exception {
0134   public:
0135     explicit DataSetException(const std::string& err_msg)
0136         : Exception(err_msg) {}
0137 };
0138 
0139 ///
0140 /// \brief Exception specific to HighFive Group interface
0141 ///
0142 class GroupException: public Exception {
0143   public:
0144     explicit GroupException(const std::string& err_msg)
0145         : Exception(err_msg) {}
0146 };
0147 
0148 ///
0149 /// \brief Exception specific to HighFive Property interface
0150 ///
0151 class PropertyException: public Exception {
0152   public:
0153     explicit PropertyException(const std::string& err_msg)
0154         : Exception(err_msg) {}
0155 };
0156 
0157 ///
0158 /// \brief Exception specific to HighFive Reference interface
0159 ///
0160 class ReferenceException: public Exception {
0161   public:
0162     explicit ReferenceException(const std::string& err_msg)
0163         : Exception(err_msg) {}
0164 };
0165 }  // namespace HighFive
0166 
0167 #include "bits/H5Exception_misc.hpp"