1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-16 07:07:13 +02:00

Fix the exception code and make it use pooled buffers instead of the common buffer.

This commit is contained in:
Sandu Liviu Catalin
2016-03-24 05:30:07 +02:00
parent 01bafd7c4f
commit 3762b5e2ca

View File

@ -102,18 +102,21 @@ bool SToB(CSStr str)
// ------------------------------------------------------------------------------------------------
void SqThrowF(CCStr fmt, ...)
{
// Acquire a moderately sized buffer
Buffer b(128);
// Initialize the argument list
va_list args;
va_start (args, fmt);
// Write the requested contents
if (snprintf(g_Buffer, sizeof(g_Buffer), fmt, args) < 0)
// Attempt to run the specified format
if (b.WriteF(0, fmt, args) == 0)
{
strcpy(g_Buffer, "Unknown error has occurred");
// Attempt to write a generic message at least
b.At(b.WriteS(0, "Unknown error has occurred")) = '\0';
}
// Release the argument list
va_end(args);
// Throw the exception with the resulted message
throw Sqrat::Exception(g_Buffer);
throw Sqrat::Exception(b.Get< SQChar >());
}
// ------------------------------------------------------------------------------------------------