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 namespace openPMD
12 {
20 class Error : public std::exception
21 {
22 private:
23  std::string m_what;
24 
25 protected:
26  Error(std::string what) : m_what(what)
27  {}
28 
29 public:
30  virtual const char *what() const noexcept;
31 
32  Error(Error const &) = default;
33  Error(Error &&) = default;
34 
35  Error &operator=(Error const &) = default;
36  Error &operator=(Error &&) = default;
37 
38  virtual ~Error() noexcept = default;
39 };
40 
41 namespace error
42 {
50  {
51  public:
52  std::string backend;
53  OperationUnsupportedInBackend(std::string backend_in, std::string what);
54  };
55 
62  class WrongAPIUsage : public Error
63  {
64  public:
65  WrongAPIUsage(std::string what);
66  };
67 
68  class BackendConfigSchema : public Error
69  {
70  public:
71  std::vector<std::string> errorLocation;
72 
73  BackendConfigSchema(std::vector<std::string>, std::string what);
74  };
75 
81  class Internal : public Error
82  {
83  public:
84  Internal(std::string const &what);
85  };
86 
87  /*
88  * Read error concerning a specific object.
89  */
90  class ReadError : public Error
91  {
92  public:
93  AffectedObject affectedObject;
94  Reason reason;
95  // If empty, then the error is thrown by the frontend
96  std::optional<std::string> backend;
97  std::string description; // object path, further details, ...
98 
99  ReadError(
100  AffectedObject,
101  Reason,
102  std::optional<std::string> backend_in,
103  std::string description_in);
104  };
105 
106  class NoSuchAttribute : public Error
107  {
108  public:
109  NoSuchAttribute(std::string attributeName);
110  };
111 } // namespace error
112 
118 
124 
130 } // namespace openPMD
Definition: Error.hpp:68
Internal errors that should not happen.
Definition: Error.hpp:81
Definition: Error.hpp:106
An operation was requested that is not supported in a specific backend.
Definition: Error.hpp:49
Definition: Error.hpp:90
Public definitions of openPMD-api.
The API was used in an illegal way.
Definition: Error.hpp:62
Base class for all openPMD-specific error types.
Definition: Error.hpp:20