Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/include/rti/apputils/http/common/HttpException.hpp
T

75 lines
1.9 KiB
C++

/*
* (c) Copyright, Real-Time Innovations, 2022.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef HTTP_EXCEPTION_HPP
#define HTTP_EXCEPTION_HPP
// RTI headers
#include "rti/apputils/http/common/StatusCode.hpp"
#include "rti/apputils/ServiceException.hpp"
namespace rti { namespace apputils { namespace http {
/**
* @brief Exception class for HTTP errors that inherit from ServiceException
*/
class HttpException : public ServiceException {
public:
/**
* @brief Constructor
*
* @param throwing_context The context where the exception was thrown
* @param status_code HTTP status code
* @param log_message RTILog message (it could be a format string)
*/
template <typename... Args>
HttpException(
const char *throwing_context,
StatusCode error_code,
const RTILogMessage *log_message,
Args... args)
: ServiceException(throwing_context, log_message, args...),
error_code_(error_code)
{ }
/**
* @brief Constructor
*
* @param ServiceException Service Exception to build the HttpException
* @param status_code HTTP status code
*/
HttpException(
const ServiceException& e,
StatusCode error_code)
: ServiceException(e),
error_code_(error_code)
{ }
/**
* @brief Get the HTTP status code
*
* @return HTTP status code
*/
StatusCode error_code() const
{
return error_code_;
}
private:
StatusCode error_code_;
};
}}} // namespace rti::apputils::http
#define RTI_THROW_HTTP_EXCEPTION(...) \
throw rti::apputils::http::HttpException(RTI_FUNCTION_NAME, __VA_ARGS__)
#endif // HTTP_EXCEPTION_HPP