FluxioErrorMessages.cpp
Go to the documentation of this file.
1 #include "FluxioErrorMessages.h"
2 
3 #include <string>
4 
5 namespace armarx::skills::error
6 {
7  std::string
8  formatString(const std::string& format, const std::vector<std::string>& args)
9  {
10  std::string formatted = format;
11  size_t pos = 0;
12  size_t argIndex = 0;
13 
14  while ((pos = formatted.find("%s", pos)) != std::string::npos && argIndex < args.size())
15  {
16  formatted.replace(pos, 2, args[argIndex]);
17  pos += args[argIndex].length();
18  ++argIndex;
19  }
20 
21  return formatted;
22  }
23 
24  std::string
25  createErrorMessage(ErrorCode code, const std::vector<std::string>& args)
26  {
27  switch (code)
28  {
30  return formatString("Execution with ID '%s' not found.", args);
32  return formatString("Executor with ID '%s' not found.", args);
34  return formatString(
35  "Error while getting execution runner for fluxio skill with id '%s'", args);
37  return formatString("Skill with ID '%s' could not be converted.", args);
39  return formatString("Executor with ID '%s' is not a FluxioCompositeExecutor.",
40  args);
42  return formatString("Skill with ID '%s' not found.", args);
44  return formatString("Parameter with ID '%s' not found.", args);
46  return formatString("Profile with ID '%s' not found.", args);
48  return formatString("Provider with ID '%s' not found.", args);
50  return formatString(
51  "Skill description for Skill with ID '%s' not found. Abort executing.", args);
53  return formatString("Mutex for Skill with ID '%s' could not be aquired", args);
55  return formatString("Mutex for Skill with ID '%s' could not be removed because the "
56  "user does not hold the mutex.",
57  args);
59  return formatString(
60  "Skill with ID: '%s' could not be added to provider with ID: '%s'.", args);
62  return formatString("This is a test Error with Argument: '%s'", args);
64  return formatString("Provider with ID '%s' already exists.", args);
66  return formatString("Profile with name: '%s' could not be added because it has no "
67  "Parent Profile assigned.",
68  args);
70  return formatString("Profile with name: '%s' already exists.", args);
72  return formatString("Required '%s' is missing.", args);
73  default:
74  return "Unknown error.";
75  }
76  }
77 } // namespace armarx::skills::error
armarx::skills::error::ErrorCode::NotFluxioCompExecutor
@ NotFluxioCompExecutor
armarx::skills::error
Definition: Exception.h:29
armarx::skills::error::ErrorCode::ParameterNotFound
@ ParameterNotFound
armarx::skills::error::ErrorCode::UserHasNoMutexError
@ UserHasNoMutexError
armarx::skills::error::createErrorMessage
std::string createErrorMessage(ErrorCode code, const std::vector< std::string > &args)
Definition: FluxioErrorMessages.cpp:25
armarx::skills::error::ErrorCode::AddSkillError
@ AddSkillError
armarx::skills::error::ErrorCode::MissingRequired
@ MissingRequired
armarx::skills::error::ErrorCode::ProfileHasNoParent
@ ProfileHasNoParent
armarx::skills::error::ErrorCode::RunnerNotFound
@ RunnerNotFound
armarx::skills::error::ErrorCode::ConverterError
@ ConverterError
armarx::skills::error::ErrorCode::SkillNotFound
@ SkillNotFound
armarx::skills::error::ErrorCode::GenericMutexError
@ GenericMutexError
armarx::skills::error::ErrorCode::ProviderNotFound
@ ProviderNotFound
armarx::skills::error::ErrorCode::ExecutionNotFound
@ ExecutionNotFound
armarx::skills::error::ErrorCode::ExecutorNotFound
@ ExecutorNotFound
armarx::skills::error::ErrorCode::ProfileNotFound
@ ProfileNotFound
armarx::skills::error::ErrorCode::SkillDescNotFound
@ SkillDescNotFound
armarx::skills::error::ErrorCode::TestError
@ TestError
armarx::skills::error::ErrorCode
ErrorCode
Definition: FluxioErrorMessages.h:6
armarx::skills::error::formatString
std::string formatString(const std::string &format, const std::vector< std::string > &args)
Definition: FluxioErrorMessages.cpp:8
FluxioErrorMessages.h
armarx::skills::error::ErrorCode::ProviderAlreadyExists
@ ProviderAlreadyExists
armarx::skills::error::ErrorCode::ProfileAlreadyExists
@ ProfileAlreadyExists