ArMemError.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdexcept>
4 
5 #include <SimoxUtility/meta/type_name.h>
6 
7 namespace armarx::armem
8 {
9  class MemoryID;
10 }
11 
12 namespace armarx::armem::error
13 {
14 
15  /**
16  * @brief Base class for all exceptions thrown by the armem library.
17  */
18  class ArMemError : public std::runtime_error
19  {
20  public:
21  ArMemError(const std::string& msg);
22  };
23 
24  /**
25  * @brief Indicates that an argument was invalid.
26  */
27  class InvalidArgument : public ArMemError
28  {
29  public:
30  InvalidArgument(const std::string& argument,
31  const std::string& function,
32  const std::string& message);
33 
34  static std::string makeMsg(const std::string& argument,
35  const std::string& function,
36  const std::string& message);
37  };
38 
39  /**
40  * @brief Indicates that a name in a given ID does not match a container's own name.
41  */
43  {
44  public:
45  ContainerNameMismatch(const std::string& gottenName,
46  const std::string& containerTerm,
47  const std::string& containerName);
48 
49  static std::string makeMsg(const std::string& gottenName,
50  const std::string& containerTerm,
51  const std::string& containerName);
52  };
53 
54  /**
55  * @brief Indicates that a name in a given ID does not match a container's own name.
56  */
58  {
59  public:
60  ContainerEntryAlreadyExists(const std::string& existingTerm,
61  const std::string& existingName,
62  const std::string& ownTerm,
63  const std::string& ownName);
64 
65  static std::string makeMsg(const std::string& existingTerm,
66  const std::string& existingName,
67  const std::string& ownTerm,
68  const std::string& ownName);
69  };
70 
71  /**
72  * @brief Indicates that a container did not have an entry under a given name.
73  */
74  class MissingEntry : public ArMemError
75  {
76  public:
77  template <class MissingT, class ContainerT>
78  static MissingEntry
79  create(const std::string& missingKey, const ContainerT& container)
80  {
81  return MissingEntry(MissingT::getLevelName(),
82  missingKey,
83  ContainerT::getLevelName(),
84  container.getKeyString(),
85  container.size());
86  }
87 
88  MissingEntry(const std::string& missingTerm,
89  const std::string& missingName,
90  const std::string& containerTerm,
91  const std::string& containerName,
92  size_t containerSize);
93 
94  static std::string makeMsg(const std::string& missingTerm,
95  const std::string& missingName,
96  const std::string& containerTerm,
97  const std::string& containerName,
98  size_t size);
99  };
100 
101  /**
102  * @brief Indicates that an operation requiring at least one element to exist
103  * failed because there were no such entries.
104  */
105  class NoSuchEntries : public ArMemError
106  {
107  public:
108  NoSuchEntries(const std::string& missingTerm,
109  const std::string& containerTerm,
110  const MemoryID& containerID,
111  const std::string& message = "");
112 
113  static std::string makeMsg(const std::string& missingTerm,
114  const std::string& containerTerm,
115  const MemoryID& containerID,
116  const std::string& message = "");
117  };
118 
119  /**
120  * @brief Indicates that a container did have an entry, but the entry's data was
121  * null when trying to access it.
122  */
123  class MissingData : public ArMemError
124  {
125  public:
126  MissingData(const std::string& missingTerm,
127  const std::string& missingName,
128  const std::string& ownTerm,
129  const std::string& ownName);
130 
131  static std::string makeMsg(const std::string& missingTerm,
132  const std::string& missingName,
133  const std::string& ownTerm,
134  const std::string& ownName);
135  };
136 
137  /**
138  * @brief Indicates that a string could not be parsed as integer.
139  */
141  {
142  public:
143  ParseIntegerError(std::string string, std::string semanticName);
144 
145  static std::string makeMsg(std::string string, std::string semanticName);
146  };
147 
148  /**
149  * @brief Indicates that a memory ID is invalid, e.g. does not contain necessary information.
150  */
152  {
153  public:
154  InvalidMemoryID(const MemoryID& id, const std::string& message);
155 
156  static std::string makeMsg(const MemoryID& id, const std::string& message);
157  };
158 
159  /**
160  * @brief Indicates that an entity's history was queried, but is empty.
161  */
163  {
164  public:
165  EntityHistoryEmpty(const std::string& entityName, const std::string& message = "");
166 
167  static std::string makeMsg(const std::string& entityName, const std::string& message = "");
168  };
169 
170  /**
171  * @brief Indicates that an entity's history was queried, but is empty.
172  */
174  {
175  public:
176  template <class QueryType>
177  UnknownQueryType(const std::string& term, const QueryType& query) :
178  UnknownQueryType(term, simox::meta::get_type_name(query))
179  {
180  }
181 
182  UnknownQueryType(const std::string& term, const std::string& typeName);
183 
184  static std::string makeMsg(const std::string& term, const std::string& typeName);
185  };
186 
187  /**
188  * @brief Indicates that a query resulted in an Error.
189  */
190  class QueryFailed : public ArMemError
191  {
192  public:
193  QueryFailed(const std::string& memory, const std::string& message = "");
194 
195  static std::string makeMsg(const std::string& memory, const std::string& message = "");
196  };
197 
198  /**
199  * @brief Indicates that something went wrong when accessing the filesystem.
200  */
201  class IOError : public ArMemError
202  {
203  public:
204  IOError(const std::string& path, const std::string& message = "");
205 
206  static std::string makeMsg(const std::string& path, const std::string& message = "");
207 
208 
209  std::string path;
210  };
211 
212  /**
213  * @brief Indicates that a proxy required for an operation wasn't usable.
214  */
215  class ProxyNotSet : public ArMemError
216  {
217  public:
218  ProxyNotSet(const std::string& proxyName, const std::string& message = "");
219 
220  static std::string makeMsg(const std::string& proxyName, const std::string& message = "");
221  };
222 
223  /**
224  * @brief Indicates that a ReadStream is already polling when a polling method was called.
225  */
227  {
228  public:
229  ReadStreamAlreadyPolling(const MemoryID& queriedId, const std::string& calledFunction);
230 
231  static std::string makeMsg(const MemoryID& queriedId, const std::string& calledFunction);
232  };
233 
234 } // namespace armarx::armem::error
armarx::armem::error::InvalidArgument::makeMsg
static std::string makeMsg(const std::string &argument, const std::string &function, const std::string &message)
Definition: ArMemError.cpp:25
armarx::armem::error::ContainerNameMismatch::makeMsg
static std::string makeMsg(const std::string &gottenName, const std::string &containerTerm, const std::string &containerName)
Definition: ArMemError.cpp:50
armarx::armem::error::InvalidArgument
Indicates that an argument was invalid.
Definition: ArMemError.h:27
armarx::armem::error::NoSuchEntries::makeMsg
static std::string makeMsg(const std::string &missingTerm, const std::string &containerTerm, const MemoryID &containerID, const std::string &message="")
Definition: ArMemError.cpp:111
armarx::armem::error::ContainerEntryAlreadyExists::ContainerEntryAlreadyExists
ContainerEntryAlreadyExists(const std::string &existingTerm, const std::string &existingName, const std::string &ownTerm, const std::string &ownName)
Definition: ArMemError.cpp:60
armarx::armem::error::ParseIntegerError::ParseIntegerError
ParseIntegerError(std::string string, std::string semanticName)
Definition: ArMemError.cpp:141
armarx::armem::error::IOError::makeMsg
static std::string makeMsg(const std::string &path, const std::string &message="")
Definition: ArMemError.cpp:221
armarx::armem::error::NoSuchEntries
Indicates that an operation requiring at least one element to exist failed because there were no such...
Definition: ArMemError.h:105
armarx::armem
Definition: LegacyRobotStateMemoryAdapter.cpp:31
armarx::armem::error::ProxyNotSet::makeMsg
static std::string makeMsg(const std::string &proxyName, const std::string &message="")
Definition: ArMemError.cpp:238
armarx::armem::error::InvalidMemoryID::makeMsg
static std::string makeMsg(const MemoryID &id, const std::string &message)
Definition: ArMemError.cpp:160
armarx::armem::error::ArMemError::ArMemError
ArMemError(const std::string &msg)
Definition: ArMemError.cpp:13
armarx::armem::error::IOError::path
std::string path
Definition: ArMemError.h:209
armarx::armem::error::ArMemError
Base class for all exceptions thrown by the armem library.
Definition: ArMemError.h:18
armarx::armem::error::MissingEntry::MissingEntry
MissingEntry(const std::string &missingTerm, const std::string &missingName, const std::string &containerTerm, const std::string &containerName, size_t containerSize)
Definition: ArMemError.cpp:80
armarx::armem::error::InvalidArgument::InvalidArgument
InvalidArgument(const std::string &argument, const std::string &function, const std::string &message)
Definition: ArMemError.cpp:17
message
message(STATUS "Boost-Library-Dir: " "${Boost_LIBRARY_DIRS}") message(STATUS "Boost-LIBRARIES
Definition: CMakeLists.txt:8
armarx::armem::error::MissingEntry::makeMsg
static std::string makeMsg(const std::string &missingTerm, const std::string &missingName, const std::string &containerTerm, const std::string &containerName, size_t size)
Definition: ArMemError.cpp:90
armarx::memory
Brief description of class memory.
Definition: memory.h:39
armarx::armem::error::ContainerEntryAlreadyExists::makeMsg
static std::string makeMsg(const std::string &existingTerm, const std::string &existingName, const std::string &ownTerm, const std::string &ownName)
Definition: ArMemError.cpp:69
armarx::armem::error::ProxyNotSet
Indicates that a proxy required for an operation wasn't usable.
Definition: ArMemError.h:215
armarx::armem::error::EntityHistoryEmpty::EntityHistoryEmpty
EntityHistoryEmpty(const std::string &entityName, const std::string &message="")
Definition: ArMemError.cpp:167
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::error::QueryFailed::makeMsg
static std::string makeMsg(const std::string &memory, const std::string &message="")
Definition: ArMemError.cpp:208
armarx::armem::error::MissingData::makeMsg
static std::string makeMsg(const std::string &missingTerm, const std::string &missingName, const std::string &ownTerm, const std::string &ownName)
Definition: ArMemError.cpp:130
armarx::armem::error::MissingData::MissingData
MissingData(const std::string &missingTerm, const std::string &missingName, const std::string &ownTerm, const std::string &ownName)
Definition: ArMemError.cpp:121
armarx::armem::error::MissingData
Indicates that a container did have an entry, but the entry's data was null when trying to access it.
Definition: ArMemError.h:123
armarx::armem::error::ContainerNameMismatch::ContainerNameMismatch
ContainerNameMismatch(const std::string &gottenName, const std::string &containerTerm, const std::string &containerName)
Definition: ArMemError.cpp:42
armarx::armem::error::QueryFailed::QueryFailed
QueryFailed(const std::string &memory, const std::string &message="")
Definition: ArMemError.cpp:202
armarx::armem::error::IOError::IOError
IOError(const std::string &path, const std::string &message="")
Definition: ArMemError.cpp:215
armarx::armem::error::InvalidMemoryID
Indicates that a memory ID is invalid, e.g.
Definition: ArMemError.h:151
armarx::armem::error::IOError
Indicates that something went wrong when accessing the filesystem.
Definition: ArMemError.h:201
armarx::armem::error::EntityHistoryEmpty
Indicates that an entity's history was queried, but is empty.
Definition: ArMemError.h:162
armarx::armem::error::ContainerNameMismatch
Indicates that a name in a given ID does not match a container's own name.
Definition: ArMemError.h:42
armarx::armem::error::ParseIntegerError::makeMsg
static std::string makeMsg(std::string string, std::string semanticName)
Definition: ArMemError.cpp:147
armarx::armem::error::QueryFailed
Indicates that a query resulted in an Error.
Definition: ArMemError.h:190
armarx::armem::error::EntityHistoryEmpty::makeMsg
static std::string makeMsg(const std::string &entityName, const std::string &message="")
Definition: ArMemError.cpp:174
armarx::armem::error::NoSuchEntries::NoSuchEntries
NoSuchEntries(const std::string &missingTerm, const std::string &containerTerm, const MemoryID &containerID, const std::string &message="")
Definition: ArMemError.cpp:102
armarx::armem::error::ReadStreamAlreadyPolling::makeMsg
static std::string makeMsg(const MemoryID &queriedId, const std::string &calledFunction)
Definition: ArMemError.cpp:256
armarx::armem::error::UnknownQueryType::makeMsg
static std::string makeMsg(const std::string &term, const std::string &typeName)
Definition: ArMemError.cpp:195
armarx::armem::error::ContainerEntryAlreadyExists
Indicates that a name in a given ID does not match a container's own name.
Definition: ArMemError.h:57
armarx::armem::error::ParseIntegerError
Indicates that a string could not be parsed as integer.
Definition: ArMemError.h:140
armarx::armem::error::ProxyNotSet::ProxyNotSet
ProxyNotSet(const std::string &proxyName, const std::string &message="")
Definition: ArMemError.cpp:232
armarx::armem::error::MissingEntry::create
static MissingEntry create(const std::string &missingKey, const ContainerT &container)
Definition: ArMemError.h:79
armarx::armem::error::ReadStreamAlreadyPolling
Indicates that a ReadStream is already polling when a polling method was called.
Definition: ArMemError.h:226
armarx::armem::error::InvalidMemoryID::InvalidMemoryID
InvalidMemoryID(const MemoryID &id, const std::string &message)
Definition: ArMemError.cpp:154
simox
Definition: Impl.cpp:40
armarx::armem::error::UnknownQueryType
Indicates that an entity's history was queried, but is empty.
Definition: ArMemError.h:173
armarx::armem::error::ReadStreamAlreadyPolling::ReadStreamAlreadyPolling
ReadStreamAlreadyPolling(const MemoryID &queriedId, const std::string &calledFunction)
Definition: ArMemError.cpp:249
armarx::armem::error
Definition: ArMemError.cpp:9
armarx::armem::error::MissingEntry
Indicates that a container did not have an entry under a given name.
Definition: ArMemError.h:74
armarx::armem::error::UnknownQueryType::UnknownQueryType
UnknownQueryType(const std::string &term, const QueryType &query)
Definition: ArMemError.h:177
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29