FluxioException.cpp
Go to the documentation of this file.
1#include "FluxioException.h"
2
4
6{
7 void
8 FluxioException::addToContext(const std::optional<std::string>& contextItem,
9 const std::optional<std::string>& className,
10 const std::optional<std::string>& methodName,
11 const std::optional<int>& line)
12 {
13 std::ostringstream oss;
14 if (className.has_value() && methodName.has_value() && line.has_value())
15 {
16 oss << "From class " << className.value() << " in method " << methodName.value()
17 << " in line " << line.value();
18 if (contextItem.has_value())
19 {
20 oss << "\n" << contextItem.value();
21 }
22 }
23 else if (contextItem.has_value())
24 {
25 oss << contextItem.value();
26 }
27 contextList.push_back(oss.str());
28 }
29
31 FluxioException::create(const std::string& message,
32 const FluxioExceptionType& type,
33 const std::string& className,
34 const char* function,
35 int line)
36 {
37 FluxioException error(message, type);
38 error.addToContext(std::nullopt, className, function, line);
39 return error;
40 }
41
42 skills::manager::dto::FluxioException
44 {
45 skills::manager::dto::FluxioException ret;
46 ret.message = message;
47 ret.type = FluxioExceptionTypeToString(type);
48 ret.contextList = contextList;
49 return ret;
50 }
51
52 std::string
54 {
55 switch (t)
56 {
58 return "BAD_REQUEST";
60 return "FORBIDDEN";
62 return "NOT_FOUND";
64 return "UNAUTHORIZED";
65 default:
66 ARMARX_WARNING << "Unknown error type: " << static_cast<int>(t);
67 return "UNKNOWN";
68 }
69 }
70} // namespace armarx::skills::error
A base class for skill exceptions.
static FluxioException create(const std::string &message, const FluxioExceptionType &type, const std::string &className, const char *function, int line)
static std::string FluxioExceptionTypeToString(const FluxioExceptionType &type)
skills::manager::dto::FluxioException toManagerIce() const
void addToContext(const std::optional< std::string > &contextItem=std::nullopt, const std::optional< std::string > &className=std::nullopt, const std::optional< std::string > &methodName=std::nullopt, const std::optional< int > &line=std::nullopt)
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193