FluxioErrorMessages.cpp
Go to the documentation of this file.
2
3#include <string>
4
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
std::string createErrorMessage(ErrorCode code, const std::vector< std::string > &args)
std::string formatString(const std::string &format, const std::vector< std::string > &args)