12 #ifndef HPP_SERVICE_SERVICE_EXCEPTION_HPP_
13 #define HPP_SERVICE_SERVICE_EXCEPTION_HPP_
15 #include "routingservice/routingservice_log.h"
17 #include <dds/core/types.hpp>
18 #include <dds/core/Exception.hpp>
20 namespace rti {
namespace service {
23 void initialize_exception_message(
25 const char *throwing_context,
26 const RTILogMessage *log_message,
29 RTIOsapiUtility_snprintf(
34 RTIOsapiUtility_vsnprintf(
35 &message[0] + strlen(message.c_str()),
36 (
size_t) RTI_LOG_MSG_SIZE_MAX - strlen(message.c_str()),
42 class ServiceException : public std::exception {
46 const char *throwing_context,
47 const RTILogMessage *log_message,
49 : message_(RTI_LOG_MSG_SIZE_MAX,
'\0'),
50 error_code_(log_message->logNumber)
53 va_start(ap, log_message);
54 initialize_exception_message(
62 int32_t error_code()
const
67 virtual const char* what()
const throw ()
69 return message_.c_str();
72 virtual ~ServiceException() throw ()
87 #define RTI_THROW_SERVICE_EXCEPTION( ...) \
88 throw rti::service::ServiceException(\