Failed engine/client assertion
- Separated 'FailedAssertion' into 'FailedEngineAssertion' and
      'FailedClientAssertion'
- Minor adjustment to the change log
			
			
This commit is contained in:
		
							parent
							
								
									ac8c515b06
								
							
						
					
					
						commit
						2967cf5675
					
				
					 4 changed files with 51 additions and 23 deletions
				
			
		| 
						 | 
				
			
			@ -9,19 +9,16 @@
 | 
			
		|||
 | 
			
		||||
#include <memory>
 | 
			
		||||
 | 
			
		||||
#define LT_WIN(x) // windows
 | 
			
		||||
#define LT_LIN(x) // linux
 | 
			
		||||
#define LT_MAC(x) // mac
 | 
			
		||||
 | 
			
		||||
#define LT_VERSION "0.7.0" 
 | 
			
		||||
// version
 | 
			
		||||
#define LT_VERSION "0.7.2" 
 | 
			
		||||
///*** [  CHANGE_LOG  ] ***///
 | 
			
		||||
// --------------------------------------------------------------------
 | 
			
		||||
// Note: change log starts from 2021-07-21, the starting version is 
 | 
			
		||||
// 0.7.0, I came up with that version because of the engine's major
 | 
			
		||||
// features: 
 | 
			
		||||
//     projects: 'Engine', 'Sandbox', 'Mirror' + 0.3
 | 
			
		||||
//     graphics apis: 'OpenGL', 'DirectX11' + 0.2
 | 
			
		||||
//     platforms: 'Windows', 'Linux' + 0.2
 | 
			
		||||
// Note: change log starts from 2021-07-21, the starting version is 0.7.0,
 | 
			
		||||
// I came up with that version because of:
 | 
			
		||||
//     projects: 'Engine', 'Sandbox', 'Mirror' [+0.3]
 | 
			
		||||
//     graphics apis: 'OpenGL', 'DirectX11'    [+0.2]
 | 
			
		||||
//     platforms: 'Windows', 'Linux'           [+0.2]
 | 
			
		||||
// --------------------------------------------------------------------
 | 
			
		||||
// 
 | 
			
		||||
// 0.7.0: started the change log
 | 
			
		||||
| 
						 | 
				
			
			@ -29,8 +26,17 @@
 | 
			
		|||
// 0.7.1: [ LT_BREAK ]
 | 
			
		||||
//     - Added the 'LT_BERAK' macro, a portable debug-trap
 | 
			
		||||
// 
 | 
			
		||||
// 0.7.2: [ Failed engine/client assertion ]
 | 
			
		||||
//     - Separated 'FailedAssertion' into 'FailedEngineAssertion' and 'FailedClientAssertion'
 | 
			
		||||
//     - Minor adjustment to the change log
 | 
			
		||||
//
 | 
			
		||||
///*** [  CHANGE_LOG  ] ***///
 | 
			
		||||
 | 
			
		||||
// platform
 | 
			
		||||
#define LT_WIN(x) // windows
 | 
			
		||||
#define LT_LIN(x) // linux
 | 
			
		||||
#define LT_MAC(x) // mac
 | 
			
		||||
 | 
			
		||||
#if defined(LIGHT_PLATFORM_WINDOWS)
 | 
			
		||||
	#define LT_BUILD_PLATFORM "Windows"
 | 
			
		||||
	#define LT_WIN(x) x
 | 
			
		||||
| 
						 | 
				
			
			@ -48,11 +54,13 @@
 | 
			
		|||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// operations
 | 
			
		||||
#define BIT(x) 1 << x
 | 
			
		||||
 | 
			
		||||
// assertions
 | 
			
		||||
// #todo: log to file in distribution builds
 | 
			
		||||
#define LT_ENGINE_ASSERT(x, ...) { if(!(x)) { LT_ENGINE_CRITICAL(__VA_ARGS__); LT_BREAK(); throw ::Light::FailedAssertion(__FILE__, __LINE__); } }
 | 
			
		||||
#define LT_CLIENT_ASSERT(x, ...) { if(!(x)) { LT_CLIENT_CRITICAL(__VA_ARGS__); LT_BREAK(); } }
 | 
			
		||||
#define LT_ENGINE_ASSERT(x, ...) { if(!(x)) { LT_ENGINE_CRITICAL(__VA_ARGS__); LT_BREAK(); throw ::Light::FailedEngineAssertion(__FILE__, __LINE__); } }
 | 
			
		||||
#define LT_CLIENT_ASSERT(x, ...) { if(!(x)) { LT_CLIENT_CRITICAL(__VA_ARGS__); LT_BREAK(); throw ::Light::FailedClientAssertion(__FILE__, __LINE__); } } }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///*** [  PORTABLES  ] ***///
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,9 +11,14 @@
 | 
			
		|||
 | 
			
		||||
namespace Light {
 | 
			
		||||
 | 
			
		||||
	FailedAssertion::FailedAssertion(const char* file, int line)
 | 
			
		||||
	FailedEngineAssertion::FailedEngineAssertion(const char* file, int line)
 | 
			
		||||
	{
 | 
			
		||||
		LT_ENGINE_CRITICAL("FailedAssertion::FailedAssertion: assertion failed in: {} (line {})", file, line);
 | 
			
		||||
		LT_ENGINE_CRITICAL("FailedAssertion::FailedAssertion: engine assertion failed in: {} (line {})", file, line);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	FailedClientAssertion::FailedClientAssertion(const char* file, int line)
 | 
			
		||||
	{
 | 
			
		||||
		LT_ENGINE_CRITICAL("FailedClientAssertion::FailedClientAssertion: client assertion failed in: {} (line {})", file, line);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	glException::glException(unsigned int source, unsigned int type, unsigned int id, const char* msg)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,9 +4,14 @@
 | 
			
		|||
 | 
			
		||||
namespace Light {
 | 
			
		||||
	
 | 
			
		||||
	struct FailedAssertion : std::exception
 | 
			
		||||
	struct FailedEngineAssertion : std::exception
 | 
			
		||||
	{
 | 
			
		||||
		FailedAssertion(const char* file, int line);
 | 
			
		||||
		FailedEngineAssertion(const char* file, int line);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	struct FailedClientAssertion : std::exception
 | 
			
		||||
	{
 | 
			
		||||
		FailedClientAssertion(const char* file, int line);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	// OpenGL
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,20 +20,25 @@ int main(int argc, char** argv)
 | 
			
		|||
 | 
			
		||||
		application->GameLoop();
 | 
			
		||||
	}
 | 
			
		||||
	catch (Light::FailedAssertion)
 | 
			
		||||
	catch (Light::FailedEngineAssertion)
 | 
			
		||||
	{
 | 
			
		||||
		LT_ENGINE_CRITICAL("main: exitting due to unhandled 'FailedAssertion'");
 | 
			
		||||
		LT_ENGINE_CRITICAL("main: exitting due to unhandled 'FailedEngineAssertion'");
 | 
			
		||||
		exitCode = -1;
 | 
			
		||||
	}
 | 
			
		||||
	catch (Light::FailedClientAssertion)
 | 
			
		||||
	{
 | 
			
		||||
		LT_ENGINE_CRITICAL("main: exitting due to unhandled 'FailedClientAssertion'");
 | 
			
		||||
		exitCode = -2;
 | 
			
		||||
	}
 | 
			
		||||
	catch(Light::glException)
 | 
			
		||||
	{
 | 
			
		||||
		LT_ENGINE_CRITICAL("main: exitting due to unhandled 'glException'");
 | 
			
		||||
		exitCode = -2;
 | 
			
		||||
		exitCode = -3;
 | 
			
		||||
	}
 | 
			
		||||
	catch (Light::dxException)
 | 
			
		||||
	{
 | 
			
		||||
		LT_ENGINE_CRITICAL("main: exitting due to unhandled 'dxException'");
 | 
			
		||||
		exitCode = -3;
 | 
			
		||||
		exitCode = -4;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	delete application;
 | 
			
		||||
| 
						 | 
				
			
			@ -60,15 +65,20 @@ int main(int argc, char* argv[])
 | 
			
		|||
 | 
			
		||||
		application->GameLoop();
 | 
			
		||||
	}
 | 
			
		||||
	catch (Light::FailedAssertion)
 | 
			
		||||
	catch (Light::FailedEngineAssertion)
 | 
			
		||||
	{
 | 
			
		||||
		LT_ENGINE_CRITICAL("main: exitting due to unhandled 'FailedAssertion'");
 | 
			
		||||
		LT_ENGINE_CRITICAL("main: exitting due to unhandled 'FailedEngineAssertion'");
 | 
			
		||||
		exitCode = -1;
 | 
			
		||||
	}
 | 
			
		||||
	catch (Light::FailedClientAssertion)
 | 
			
		||||
	{
 | 
			
		||||
		LT_ENGINE_CRITICAL("main: exitting due to unhandled 'FailedClientAssertion'");
 | 
			
		||||
		exitCode = -2;
 | 
			
		||||
	}
 | 
			
		||||
	catch(Light::glException)
 | 
			
		||||
	{
 | 
			
		||||
		LT_ENGINE_CRITICAL("main: exitting due to unhandled 'glException'");
 | 
			
		||||
		exitCode = -2;
 | 
			
		||||
		exitCode = -3;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	delete application;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue