mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-21 20:27:13 +01:00
Implement a formatted Squirrel error throwing utility.
This commit is contained in:
parent
e8027dcb3d
commit
f048950d20
@ -98,6 +98,11 @@ CSStr ToStrF(CCStr str, ...);
|
|||||||
*/
|
*/
|
||||||
CSStr ToStringF(CCStr str, ...);
|
CSStr ToStringF(CCStr str, ...);
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Generate a formatted string and throw it as a squirrel exception.
|
||||||
|
*/
|
||||||
|
SQRESULT SqThrowErrorF(HSQUIRRELVM vm, CCStr str, ...);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Simple function to check whether the specified string can be considered as a boolean value
|
* Simple function to check whether the specified string can be considered as a boolean value
|
||||||
*/
|
*/
|
||||||
|
@ -208,6 +208,23 @@ CSStr ToStringF(CSStr str, ...)
|
|||||||
return b.Get< SQChar >();
|
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)
|
bool SToB(CSStr str)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user