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