1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Make the audit stage optional.

Also fix bug where the execution function is not invoked without binding an audit function first which enables it.
This commit is contained in:
Sandu Liviu Catalin 2021-05-05 17:51:07 +03:00
parent 47ff628a46
commit cb0598d228

View File

@ -400,16 +400,23 @@ int32_t Controller::Exec(Context & ctx)
args = LightObj(arr.GetObj());
}
// Allow the user to audit the command parameters
try
if (!ctx.mInstance->m_OnAudit.IsNull())
{
result = ctx.mInstance->Audit(ctx.mInvoker, args);
try
{
result = ctx.mInstance->Audit(ctx.mInvoker, args);
}
catch (const std::exception & e)
{
// Let's store the exception message
ctx.mBuffer.WriteS(0, e.what());
// Specify that the command execution failed
failed = true;
}
}
catch (const std::exception & e)
else
{
// Let's store the exception message
ctx.mBuffer.WriteS(0, e.what());
// Specify that the command execution failed
failed = true;
result = SQTrue;
}
// Did parameter audit succeeded?
if (result && !failed)