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

Implement a formatted Squirrel error throwing utility.

This commit is contained in:
Sandu Liviu Catalin
2017-06-16 02:23:24 +03:00
parent e8027dcb3d
commit f048950d20
2 changed files with 22 additions and 0 deletions

View File

@ -208,6 +208,23 @@ CSStr ToStringF(CSStr str, ...)
return b.Get< SQChar >();
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqThrowErrorF(HSQUIRRELVM vm, CCStr str, ...)
{
// Prepare the arguments list
va_list args;
va_start(args, str);
// Write the requested contents
if (std::vsnprintf(g_Buffer, sizeof(g_Buffer), str, args) < 0)
{
return sq_throwerror(vm, _SC("Formatting error occurred while throwing a script error"));
}
// Finalize the argument list
va_end(args);
// Throw the resulted string
return sq_throwerror(vm, g_Buffer);
}
// ------------------------------------------------------------------------------------------------
bool SToB(CSStr str)
{