60 std::string _error_msg;
86 std::ostringstream
_os;
97 bool enable_logging()
const;
107 template <
typename Last>
122 template <
typename First,
typename... Rest>
123 void report_error(std::ostringstream& oss,
const First& first,
const Rest&... rest)
138 template <
typename... All>
141 if (status !=
nullptr)
143 std::ostringstream oss;
159 template <
typename T>
162 if (sbuilder.
_status !=
nullptr) { sbuilder.
_os <<
", " << val; }
182 template <
typename Last>
185 return sbuilder << last;
198 template <
typename First,
typename... Rest>
209 #define RETURN_ERROR(trace, status, code, ...) \
211 if (status != nullptr) \
213 reinforcement_learning::status_builder sbuilder(trace, status, reinforcement_learning::error_code::code); \
214 sbuilder << reinforcement_learning::error_code::code##_s; \
215 return report_error(sbuilder); \
217 return reinforcement_learning::error_code::code; \
223 #define RETURN_ERROR_ARG(trace, status, code, ...) \
225 if (status != nullptr) \
227 reinforcement_learning::status_builder sbuilder(trace, status, reinforcement_learning::error_code::code); \
228 sbuilder << reinforcement_learning::error_code::code##_s; \
229 return report_error(sbuilder, __VA_ARGS__); \
231 return reinforcement_learning::error_code::code; \
237 #define RETURN_ERROR_LS(trace, status, code) \
238 reinforcement_learning::status_builder sbuilder(trace, status, reinforcement_learning::error_code::code); \
239 return sbuilder << reinforcement_learning::error_code::code##_s
244 #define RETURN_IF_FAIL(x) \
246 int retval__LINE__ = (x); \
247 if (retval__LINE__ != 0) { return retval__LINE__; } \
Report status of all API calls.
Definition: api_status.h:22
static void try_update(api_status *status, int new_code, const char *new_msg)
Helper method for returning error object Checks to see if api_status is not null before setting the e...
const char * get_error_msg() const
(API Error Codes) Get the error msg string All API calls will return a status code....
int get_error_code() const
(API Error Codes) Get the error code All API calls will return a status code. If the optional api_sta...
static void try_clear(api_status *status)
Helper method to clear the error object Checks to see if api_status is not null before clearing curre...
Definition of all API error return codes and descriptions.
[Error Generator]
Definition: live_model.h:25
reinforcement_learning::status_builder & operator<<(reinforcement_learning::status_builder &sbuilder, const T &val)
left shift operator to serialize types into stringstream held in status_builder
Definition: api_status.h:160
void report_error(std::ostringstream &oss, const Last &last)
Ends recursion of report_error variadic template with the Last argument.
Definition: api_status.h:108
Helper class used in report_error template funcstions to return status from API calls.
Definition: api_status.h:67
status_builder(i_trace *trace, api_status *status, int code)
Construct a new status builder object.
std::ostringstream _os
String stream used to serialize detailed error message.
Definition: api_status.h:86
int _code
Error code.
Definition: api_status.h:82
api_status * _status
Api status object which can be null.
Definition: api_status.h:84