2022-09-08 12:51:23 +08:00
|
|
|
/****************************************************************************************
|
|
|
|
* \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 <exception>
|
|
|
|
#include <string>
|
|
|
|
#include <source_location>
|
|
|
|
#include <string_view>
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
// Project Headers
|
2022-11-15 03:03:37 +08:00
|
|
|
#include "Logger/SHLogger.h"
|
2022-09-08 12:51:23 +08:00
|
|
|
|
|
|
|
namespace SHADE
|
|
|
|
{
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
/* Concepts */
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
template <typename ExceptionType>
|
|
|
|
concept IsException = std::is_base_of_v<std::exception, ExceptionType>;
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
/* 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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-09-27 16:24:08 +08:00
|
|
|
#ifdef _DEBUG
|
|
|
|
#define SHASSERT(cond, msg) \
|
|
|
|
if (!(cond)) \
|
|
|
|
{ \
|
|
|
|
SHLOGV_CRITICAL(msg) \
|
|
|
|
std::abort(); \
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define SHASSERT(cond, msg) { }
|
|
|
|
#endif
|