1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Added Runtime.AddErrorHandler

This commit is contained in:
Brian Fiete 2022-02-11 08:12:30 -05:00
parent 9e80281d1a
commit 657a64f59c
8 changed files with 192 additions and 6 deletions

View file

@ -3,7 +3,7 @@
#include "BeefySysLib/Common.h"
#include "BeefySysLib/util/String.h"
#define BFRT_VERSION 8
#define BFRT_VERSION 9
#ifdef BFRT_DYNAMIC
#define BFRT_EXPORT __declspec(dllexport)
@ -106,7 +106,8 @@ namespace bf
void(*DebugMessageData_SetupError)(const char* str, int32 stackWindbackCount);
void(*DebugMessageData_SetupProfilerCmd)(const char* str);
void(*DebugMessageData_Fatal)();
void(*DebugMessageData_Clear)();
void(*DebugMessageData_Clear)();
int(*CheckErrorHandler)(const char* kind, const char* arg1, const char* arg2, intptr arg3);
};
public:

View file

@ -214,6 +214,9 @@ static void TestReadCmd(Beefy::String& str);
static void Internal_FatalError(const char* error)
{
if (gBfRtCallbacks.CheckErrorHandler != NULL)
gBfRtCallbacks.CheckErrorHandler("FatalError", error, NULL, 0);
if ((gClientPipe != NULL) && (!gTestBreakOnFailure))
{
Beefy::String str = ":TestFatal\t";
@ -532,6 +535,12 @@ void* Internal::LoadSharedLibrary(char* libName)
void* libHandle = BfpDynLib_Load(libName);
if (libHandle == NULL)
{
if (gBfRtCallbacks.CheckErrorHandler != NULL)
{
if (gBfRtCallbacks.CheckErrorHandler("LoadSharedLibrary", libName, NULL, 0) == 1)
return NULL;
}
Beefy::String errorStr = StrFormat("Failed to load shared library: %s", libName);
SETUP_ERROR(errorStr.c_str(), 1);
BF_DEBUG_BREAK();
@ -558,6 +567,12 @@ void* Internal::GetSharedProcAddress(void* libHandle, char* procName)
int libFileNameLen = 4096;
BfpDynLib_GetFilePath((BfpDynLib*)libHandle, libFileName, &libFileNameLen, NULL);
if (gBfRtCallbacks.CheckErrorHandler != NULL)
{
if (gBfRtCallbacks.CheckErrorHandler("GetSharedProcAddress", libFileName, procName, 0) == 1)
return NULL;
}
Beefy::String errorStr = StrFormat("Failed to load shared procedure '%s' from '%s'", procName, libFileName);
SETUP_ERROR(errorStr.c_str(), 1);
BF_DEBUG_BREAK();