h5cpp  0.4.1
A modern C++ wrapper for the HDF5 C library
h5c_error.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2017 DESY,ESS
3 //
4 // This file is part of h5cpp.
5 //
6 // This library is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
19 // Boston, MA 02110-1301 USA
20 // ===========================================================================
21 //
22 // Author: Martin Shetty <martin.shetty@esss.se>
23 // Created on: Oct 25, 2017
24 //
25 #pragma once
26 
28 #include <sstream>
29 #include <stdexcept>
30 #include <list>
31 
32 namespace hdf5 {
33 namespace error {
34 
43 class H5CError : public std::runtime_error
44 {
45  public:
54  H5CError(const std::list<Descriptor>& H5CError);
55 
62  const char* what() const throw();
63 
69  const std::list<Descriptor>& contents() const;
70 
76  bool empty() const;
77 
78  private:
79  std::list<Descriptor> contents_;
80  std::string what_message_;
81 };
82 
83 inline H5CError::H5CError(const std::list<Descriptor>& H5CError)
84 : std::runtime_error("")
85 , contents_(H5CError)
86 {
87  std::stringstream ss;
88  for (auto& c : contents_)
89  {
90  c.extract_strings();
91  ss << c << "\n";
92  }
93  what_message_ = ss.str();
94 }
95 
96 inline const char* H5CError::what() const throw()
97 {
98  return what_message_.c_str();
99 }
100 
101 inline const std::list<Descriptor>& H5CError::contents() const
102 {
103  return contents_;
104 }
105 
106 inline bool H5CError::empty() const
107 {
108  return contents_.empty();
109 }
110 
111 } // namespace file
112 } // namespace hdf5
runtime exception containing an HDF5 error H5CError
Definition: h5c_error.hpp:43
H5CError(const std::list< Descriptor > &H5CError)
constructor
Definition: h5c_error.hpp:83
const std::list< Descriptor > & contents() const
access to error H5CError
Definition: h5c_error.hpp:101
Definition: attribute.hpp:43
bool empty() const
what it says
Definition: h5c_error.hpp:106
const char * what() const
printout of error H5CError
Definition: h5c_error.hpp:96