Added ObjectCreationException and Utility Macros
This commit is contained in:
parent
740ddc2ca6
commit
fac88781aa
|
@ -13,5 +13,6 @@ target_link_libraries(${PNAME} PRIVATE
|
|||
${CMAKE_BINARY_DIR}/3rdparty/SDL/SDL2d.lib
|
||||
)
|
||||
|
||||
add_subdirectory(exceptions)
|
||||
add_subdirectory(structures)
|
||||
add_subdirectory(graphics)
|
4
SDLU/exceptions/CMakeLists.txt
Normal file
4
SDLU/exceptions/CMakeLists.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
target_sources(${PNAME} PRIVATE
|
||||
${CMAKE_CURRENT_SORUCE_DIR}/Exceptions.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ObjectCreationException.hpp
|
||||
)
|
12
SDLU/exceptions/Exceptions.hpp
Normal file
12
SDLU/exceptions/Exceptions.hpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* @file Exceptions.hpp
|
||||
* @brief Provides utility and includes all exceptions
|
||||
* @author Lauchmelder23
|
||||
* @date 16.05.2020
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ObjectCreationException.hpp"
|
||||
|
||||
#define THROW_IF_NOT( condition, exception ) ( condition ? throw execption : false )
|
||||
#define THROW_IF( condition, exception ) ( condition ? false : throw execption )
|
30
SDLU/exceptions/ObjectCreationException.hpp
Normal file
30
SDLU/exceptions/ObjectCreationException.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* @file ObjectCreationException.hpp
|
||||
* @brief An exception object to handle failed object creations
|
||||
* @author Lauchmelder23
|
||||
* @date 16.05.2020
|
||||
*/
|
||||
#pragma once
|
||||
#include <exception>
|
||||
|
||||
namespace sdlu
|
||||
{
|
||||
class ObjectCreationException :
|
||||
virtual public std::exception
|
||||
{
|
||||
public:
|
||||
ObjectCreationException(const char* description) :
|
||||
m_pDescription(description)
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
virtual const char* what() const throw()
|
||||
{
|
||||
return m_pDescription;
|
||||
}
|
||||
|
||||
private:
|
||||
const char* m_pDescription;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue