Skip to content

Commit

Permalink
Refs #22802: Export exception classes and remove inheritance from std…
Browse files Browse the repository at this point in the history
…::exception

Signed-off-by: Carlosespicur <carlosespicur@proton.me>
  • Loading branch information
Carlosespicur committed Feb 26, 2025
1 parent 0935051 commit 366fb5a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 43 deletions.
16 changes: 8 additions & 8 deletions include/fastcdr/exceptions/BadOptionalAccessException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace exception {
* @brief This class is thrown as an exception when accessing the value of a null optional.
* @ingroup EXCEPTIONMODULE
*/
class BadOptionalAccessException : public Exception
class Cdr_DllAPI BadOptionalAccessException : public Exception
{
public:

Expand All @@ -33,31 +33,31 @@ class BadOptionalAccessException : public Exception
*
* @param message An error message. This message pointer is copied.
*/
Cdr_DllAPI BadOptionalAccessException(
BadOptionalAccessException(
const char* const& message) noexcept;

/*!
* @brief Default copy constructor.
*
* @param ex BadOptionalAccessException that will be copied.
*/
Cdr_DllAPI BadOptionalAccessException(
BadOptionalAccessException(
const BadOptionalAccessException& ex) noexcept;

/*!
* @brief Default move constructor.
*
* @param ex BadOptionalAccessException that will be moved.
*/
Cdr_DllAPI BadOptionalAccessException(
BadOptionalAccessException(
BadOptionalAccessException&& ex) noexcept;

/*!
* @brief Assigment operation.
*
* @param ex BadOptionalAccessException that will be copied.
*/
Cdr_DllAPI BadOptionalAccessException& operator =(
BadOptionalAccessException& operator =(
const BadOptionalAccessException& ex) noexcept;

/*!
Expand All @@ -69,13 +69,13 @@ class BadOptionalAccessException : public Exception
BadOptionalAccessException&& ex) noexcept;

//! @brief Default destructor
virtual Cdr_DllAPI ~BadOptionalAccessException() noexcept;
virtual ~BadOptionalAccessException() noexcept;

//! @brief This function throws the object as exception.
Cdr_DllAPI void raise() const override;
void raise() const override;

//! @brief Default message used in the library.
static Cdr_DllAPI const char* const BAD_OPTIONAL_ACCESS_MESSAGE_DEFAULT;
static const char* const BAD_OPTIONAL_ACCESS_MESSAGE_DEFAULT;
};
} //namespace exception
} //namespace fastcdr
Expand Down
16 changes: 8 additions & 8 deletions include/fastcdr/exceptions/BadParamException.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace exception {
* @brief This class is thrown as an exception when an invalid parameter is being serialized.
* @ingroup EXCEPTIONMODULE
*/
class BadParamException : public Exception
class Cdr_DllAPI BadParamException : public Exception
{
public:

Expand All @@ -33,31 +33,31 @@ class BadParamException : public Exception
*
* @param message An error message. This message pointer is copied.
*/
Cdr_DllAPI BadParamException(
BadParamException(
const char* const& message) noexcept;

/*!
* @brief Default copy constructor.
*
* @param ex BadParamException that will be copied.
*/
Cdr_DllAPI BadParamException(
BadParamException(
const BadParamException& ex) noexcept;

/*!
* @brief Default move constructor.
*
* @param ex BadParamException that will be moved.
*/
Cdr_DllAPI BadParamException(
BadParamException(
BadParamException&& ex) noexcept;

/*!
* @brief Assigment operation.
*
* @param ex BadParamException that will be copied.
*/
Cdr_DllAPI BadParamException& operator =(
BadParamException& operator =(
const BadParamException& ex) noexcept;

/*!
Expand All @@ -69,13 +69,13 @@ class BadParamException : public Exception
BadParamException&& ex) noexcept;

//! @brief Default destructor
virtual Cdr_DllAPI ~BadParamException() noexcept;
virtual ~BadParamException() noexcept;

//! @brief This function throws the object as exception.
Cdr_DllAPI void raise() const override;
void raise() const override;

//! @brief Default message used in the library.
static Cdr_DllAPI const char* const BAD_PARAM_MESSAGE_DEFAULT;
static const char* const BAD_PARAM_MESSAGE_DEFAULT;
};
} //namespace exception
} //namespace fastcdr
Expand Down
19 changes: 9 additions & 10 deletions include/fastcdr/exceptions/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "../fastcdr_dll.h"
#include <string>
#include <exception>

namespace eprosima {
namespace fastcdr {
Expand All @@ -26,22 +25,22 @@ namespace exception {
* @brief This abstract class is used to create exceptions.
* @ingroup EXCEPTIONMODULE
*/
class Exception : public std::exception
class Cdr_DllAPI Exception
{
public:

//! \brief Default destructor.
virtual Cdr_DllAPI ~Exception() noexcept;
virtual ~Exception() noexcept;

//! \brief This function throws the object as exception.
virtual Cdr_DllAPI void raise() const = 0;
virtual void raise() const = 0;

/*!
* @brief This function returns the error message.
*
* @return The error message.
*/
virtual Cdr_DllAPI const char* what() const noexcept override;
virtual const char* what() const noexcept;

protected:

Expand All @@ -50,39 +49,39 @@ class Exception : public std::exception
*
* @param message A error message. This message pointer is copied.
*/
Cdr_DllAPI Exception(
Exception(
const char* const& message) noexcept;

/*!
* @brief Default copy constructor.
*
* @param ex Exception that will be copied.
*/
Cdr_DllAPI Exception(
Exception(
const Exception& ex) noexcept;

/*!
* @brief Default move constructor.
*
* @param ex Exception that will be moved.
*/
Cdr_DllAPI Exception(
Exception(
Exception&& ex) noexcept;

/*!
* @brief Assigment operation.
*
* @param ex Exception that will be copied.
*/
Cdr_DllAPI Exception& operator =(
Exception& operator =(
const Exception& ex) noexcept;

/*!
* @brief Assigment operation.
*
* @param ex Exception that will be moved.
*/
Cdr_DllAPI Exception& operator =(
Exception& operator =(
Exception&& ex) noexcept;

private:
Expand Down
16 changes: 8 additions & 8 deletions include/fastcdr/exceptions/LockedExternalAccessException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace exception {
* @brief This class is thrown as an exception when accessing to set the value of a locked external.
* @ingroup EXCEPTIONMODULE
*/
class LockedExternalAccessException : public Exception
class Cdr_DllAPI LockedExternalAccessException : public Exception
{
public:

Expand All @@ -33,31 +33,31 @@ class LockedExternalAccessException : public Exception
*
* @param message An error message. This message pointer is copied.
*/
Cdr_DllAPI LockedExternalAccessException(
LockedExternalAccessException(
const char* const& message) noexcept;

/*!
* @brief Default copy constructor.
*
* @param ex LockedExternalAccessException that will be copied.
*/
Cdr_DllAPI LockedExternalAccessException(
LockedExternalAccessException(
const LockedExternalAccessException& ex) noexcept;

/*!
* @brief Default move constructor.
*
* @param ex LockedExternalAccessException that will be moved.
*/
Cdr_DllAPI LockedExternalAccessException(
LockedExternalAccessException(
LockedExternalAccessException&& ex) noexcept;

/*!
* @brief Assigment operation.
*
* @param ex LockedExternalAccessException that will be copied.
*/
Cdr_DllAPI LockedExternalAccessException& operator =(
LockedExternalAccessException& operator =(
const LockedExternalAccessException& ex) noexcept;

/*!
Expand All @@ -69,13 +69,13 @@ class LockedExternalAccessException : public Exception
LockedExternalAccessException&& ex) noexcept;

//! @brief Default destructor
virtual Cdr_DllAPI ~LockedExternalAccessException() noexcept;
virtual ~LockedExternalAccessException() noexcept;

//! @brief This function throws the object as exception.
Cdr_DllAPI void raise() const override;
void raise() const override;

//! @brief Default message used in the library.
static Cdr_DllAPI const char* const LOCKED_EXTERNAL_ACCESS_MESSAGE_DEFAULT;
static const char* const LOCKED_EXTERNAL_ACCESS_MESSAGE_DEFAULT;
};
} //namespace exception
} //namespace fastcdr
Expand Down
18 changes: 9 additions & 9 deletions include/fastcdr/exceptions/NotEnoughMemoryException.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace exception {
* @brief This class is thrown as an exception when the buffer's internal memory reachs its size limit.
* @ingroup EXCEPTIONMODULE
*/
class NotEnoughMemoryException : public Exception
class Cdr_DllAPI NotEnoughMemoryException : public Exception
{
public:

Expand All @@ -33,49 +33,49 @@ class NotEnoughMemoryException : public Exception
*
* @param message An error message. This message pointer is copied.
*/
Cdr_DllAPI NotEnoughMemoryException(
NotEnoughMemoryException(
const char* const& message) noexcept;

/*!
* @brief Default copy constructor.
*
* @param ex NotEnoughMemoryException that will be copied.
*/
Cdr_DllAPI NotEnoughMemoryException(
NotEnoughMemoryException(
const NotEnoughMemoryException& ex) noexcept;

/*!
* @brief Default move constructor.
*
* @param ex NotEnoughMemoryException that will be moved.
*/
Cdr_DllAPI NotEnoughMemoryException(
NotEnoughMemoryException(
NotEnoughMemoryException&& ex) noexcept;

/*!
* @brief Assigment operation.
*
* @param ex NotEnoughMemoryException that will be copied.
*/
Cdr_DllAPI NotEnoughMemoryException& operator =(
NotEnoughMemoryException& operator =(
const NotEnoughMemoryException& ex) noexcept;

/*!
* @brief Assigment operation.
*
* @param ex NotEnoughMemoryException that will be moved.
*/
Cdr_DllAPI NotEnoughMemoryException& operator =(
NotEnoughMemoryException& operator =(
NotEnoughMemoryException&& ex) noexcept;

//! @brief Default destructor
virtual Cdr_DllAPI ~NotEnoughMemoryException() noexcept;
virtual ~NotEnoughMemoryException() noexcept;

//! @brief This function throws the object as exception.
Cdr_DllAPI void raise() const override;
void raise() const override;

//! @brief Default message used in the library.
static Cdr_DllAPI const char* const NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT;
static const char* const NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT;
};
} //namespace exception
} //namespace fastcdr
Expand Down

0 comments on commit 366fb5a

Please sign in to comment.