/**************************************************************************************** * \file SHException.h * \author Diren D Bharwani, diren.dbharwani, 390002520 * \brief Interface for custom exception types of SHADE Engine. * * \copyright Copyright (C) 2022 DigiPen Institute of Technology. Reproduction or * disclosure of this file or its contents without the prior written consent * of DigiPen Institute of Technology is prohibited. ****************************************************************************************/ #pragma once #include #include #include #include #include #include // Project Headers #include "SHLogger.h" namespace SHADE { /*-----------------------------------------------------------------------------------*/ /* Concepts */ /*-----------------------------------------------------------------------------------*/ template concept IsException = std::is_base_of_v; /*-----------------------------------------------------------------------------------*/ /* Type Definitions */ /*-----------------------------------------------------------------------------------*/ /** * @brief Base exception type thrown by SHADE Engine. */ class SHException : public std::exception { public: /*---------------------------------------------------------------------------------*/ /* Constructors & Destructor */ /*---------------------------------------------------------------------------------*/ SHException ( std::string msg = "", const std::source_location& src = std::source_location::current() ) noexcept; /*---------------------------------------------------------------------------------*/ /* Function Members */ /*---------------------------------------------------------------------------------*/ const char* what() const noexcept override; protected: /*---------------------------------------------------------------------------------*/ /* Data Members */ /*---------------------------------------------------------------------------------*/ mutable std::string message; /*---------------------------------------------------------------------------------*/ /* Function Members */ /*---------------------------------------------------------------------------------*/ std::string GetOriginString() const noexcept; private: /*---------------------------------------------------------------------------------*/ /* Data Members */ /*---------------------------------------------------------------------------------*/ const std::source_location& origin; }; } #ifdef _DEBUG #define SHASSERT(cond, msg) \ if (!(cond)) \ { \ SHLOGV_CRITICAL(msg) \ std::abort(); \ } #else #define SHASSERT(cond, msg) { } #endif