openPMD-api
Error.hpp
1 #pragma once
2 
3 #include "openPMD/ThrowError.hpp"
4 
5 #include <exception>
6 #include <optional>
7 #include <string>
8 #include <utility>
9 #include <vector>
10 
11 #if defined(OPENPMD_ADIOS1_IMPLEMENTATION)
12 static_assert(false, "ADIOS1 implementation must not include Error.hpp");
13 #endif
14 
15 namespace openPMD
16 {
24 class Error : public std::exception
25 {
26 private:
27  std::string m_what;
28 
29 protected:
30  Error(std::string what) : m_what(what)
31  {}
32 
33 public:
34  virtual const char *what() const noexcept;
35 
36  Error(Error const &) = default;
37  Error(Error &&) = default;
38 
39  Error &operator=(Error const &) = default;
40  Error &operator=(Error &&) = default;
41 
42  virtual ~Error() noexcept = default;
43 };
44 
45 namespace error
46 {
54  {
55  public:
56  std::string backend;
57  OperationUnsupportedInBackend(std::string backend_in, std::string what);
58  };
59 
66  class WrongAPIUsage : public Error
67  {
68  public:
69  WrongAPIUsage(std::string what);
70  };
71 
72  class BackendConfigSchema : public Error
73  {
74  public:
75  std::vector<std::string> errorLocation;
76 
77  BackendConfigSchema(std::vector<std::string>, std::string what);
78  };
79 
85  class Internal : public Error
86  {
87  public:
88  Internal(std::string const &what);
89  };
90 
91  /*
92  * Read error concerning a specific object.
93  */
94  class ReadError : public Error
95  {
96  public:
97  AffectedObject affectedObject;
98  Reason reason;
99  // If empty, then the error is thrown by the frontend
100  std::optional<std::string> backend;
101  std::string description; // object path, further details, ...
102 
103  ReadError(
104  AffectedObject,
105  Reason,
106  std::optional<std::string> backend_in,
107  std::string description_in);
108  };
109 
110  class NoSuchAttribute : public Error
111  {
112  public:
113  NoSuchAttribute(std::string attributeName);
114  };
115 } // namespace error
116 
122 
128 
134 } // namespace openPMD
Definition: Error.hpp:72
Internal errors that should not happen.
Definition: Error.hpp:85
Definition: Error.hpp:110
An operation was requested that is not supported in a specific backend.
Definition: Error.hpp:53
Definition: Error.hpp:94
Public definitions of openPMD-api.
The API was used in an illegal way.
Definition: Error.hpp:66
Base class for all openPMD-specific error types.
Definition: Error.hpp:24