mns.cpp
Go to the documentation of this file.
1 #include "mns.h"
2 
3 #include <sstream>
4 
5 #include "../MemoryID.h"
6 
7 namespace armarx::armem::error
8 {
9 
11  const std::string& errorMessage) :
12  ArMemError(makeMsg(function, errorMessage))
13  {
14  }
15 
16  std::string
17  MemoryNameSystemQueryFailed::makeMsg(const std::string& function,
18  const std::string& errorMessage)
19  {
20  std::stringstream ss;
21  ss << "Failed to call '" << function << "' on the memory name system.\n";
22  if (not errorMessage.empty())
23  {
24  ss << "\n" << errorMessage;
25  }
26  return ss.str();
27  }
28 
30  const std::string& errorMessage) :
31  ArMemError(makeMsg(memoryID, errorMessage))
32  {
33  }
34 
35  std::string
36  CouldNotResolveMemoryServer::makeMsg(const MemoryID& memoryID, const std::string& errorMessage)
37  {
38  std::stringstream ss;
39  ss << "Could not resolve the memory name '" << memoryID << "'."
40  << "\nMemory server for '" << memoryID << "' is not registered.";
41  if (not errorMessage.empty())
42  {
43  ss << "\n" << errorMessage;
44  }
45  return ss.str();
46  }
47 
49  const std::string& verb,
50  const MemoryID& memoryID,
51  const std::string& errorMessage) :
52  ArMemError(makeMsg(verb, memoryID, errorMessage))
53  {
54  }
55 
56  std::string
58  const MemoryID& memoryID,
59  const std::string& errorMessage)
60  {
61  std::stringstream ss;
62  ss << "Failed to " << verb << " memory server for '" << memoryID
63  << "' in the Memory Name System (MNS).";
64  if (not errorMessage.empty())
65  {
66  ss << "\n" << errorMessage;
67  }
68  return ss.str();
69  }
70 
71 } // namespace armarx::armem::error
armarx::armem::error::ServerRegistrationOrRemovalFailed::ServerRegistrationOrRemovalFailed
ServerRegistrationOrRemovalFailed(const std::string &verb, const MemoryID &memoryID, const std::string &errorMessage="")
Definition: mns.cpp:48
armarx::armem::MemoryID::str
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
Definition: MemoryID.cpp:102
mns.h
armarx::armem::error::ArMemError
Base class for all exceptions thrown by the armem library.
Definition: ArMemError.h:18
armarx::armem::error::MemoryNameSystemQueryFailed::makeMsg
static std::string makeMsg(const std::string &function, const std::string &errorMessage="")
Definition: mns.cpp:17
armarx::armem::error::MemoryNameSystemQueryFailed::MemoryNameSystemQueryFailed
MemoryNameSystemQueryFailed(const std::string &function, const std::string &errorMessage="")
Definition: mns.cpp:10
armarx::armem::error::CouldNotResolveMemoryServer::makeMsg
static std::string makeMsg(const MemoryID &memoryID, const std::string &errorMessage="")
Definition: mns.cpp:36
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::error::CouldNotResolveMemoryServer::CouldNotResolveMemoryServer
CouldNotResolveMemoryServer(const MemoryID &memoryID, const std::string &errorMessage="")
Definition: mns.cpp:29
armarx::armem::index::memoryID
const MemoryID memoryID
Definition: memory_ids.cpp:28
armarx::armem::error::ServerRegistrationOrRemovalFailed::makeMsg
static std::string makeMsg(const std::string &verb, const MemoryID &memoryID, const std::string &errorMessage="")
Definition: mns.cpp:57
armarx::armem::error
Definition: ArMemError.cpp:9