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;
54  std::string backend_in, std::string const &what);
55  };
56 
63  class WrongAPIUsage : public Error
64  {
65  public:
66  WrongAPIUsage(std::string const &what);
67  };
68 
69  class BackendConfigSchema : public Error
70  {
71  public:
72  std::vector<std::string> errorLocation;
73 
74  BackendConfigSchema(std::vector<std::string>, std::string what);
75  };
76 
82  class Internal : public Error
83  {
84  public:
85  Internal(std::string const &what);
86  };
87 
88  /*
89  * Read error concerning a specific object.
90  */
91  class ReadError : public Error
92  {
93  public:
94  AffectedObject affectedObject;
95  Reason reason;
96  // If empty, then the error is thrown by the frontend
97  std::optional<std::string> backend;
98  std::string description; // object path, further details, ...
99 
100  ReadError(
101  AffectedObject,
102  Reason,
103  std::optional<std::string> backend_in,
104  std::string description_in);
105  };
106 
107  class NoSuchAttribute : public Error
108  {
109  public:
110  NoSuchAttribute(std::string attributeName);
111  };
112 } // namespace error
113 
119 
125 
131 } // namespace openPMD
Base class for all openPMD-specific error types.
Definition: Error.hpp:21
Definition: Error.hpp:70
Internal errors that should not happen.
Definition: Error.hpp:83
Definition: Error.hpp:108
An operation was requested that is not supported in a specific backend.
Definition: Error.hpp:50
Definition: Error.hpp:92
The API was used in an illegal way.
Definition: Error.hpp:64
Public definitions of openPMD-api.
Definition: Date.cpp:29