FatalError: Allow formatting the message directly

FatalError(Format(...)) was necessary previously. Actually it seems not
like a huge thing, but being able to format the string directly in
FatalError is a lot more convenient.
master
Mark 2018-04-12 20:48:43 +02:00
parent 1e060d6124
commit 25d008e99d
2 changed files with 11 additions and 4 deletions

View File

@ -14,7 +14,13 @@
<type>string</type>
<name>message</name>
<desc>Error message to be displayed</desc>
<optional/>
<optional />
</param>
<param>
<type/>
<name>...</name>
<desc>Additional parameters for text formatting.</desc>
<optional />
</param>
</params>
</syntax>
@ -46,5 +52,6 @@
<funclink>LogCallStack</funclink>
</related>
</func>
<author>Marky</author><date>2018-04</date>
<author>Newton</author><date>2011-09</date>
</funcs>

View File

@ -942,9 +942,9 @@ static long FnWildcardMatch(C4PropList * _this, C4String *psString, C4String *ps
return SWildcardMatchEx(FnStringPar(psString), FnStringPar(psWildcard));
}
static bool FnFatalError(C4PropList * _this, C4String *pErrorMsg)
static C4Value FnFatalError(C4PropList * _this, C4Value * Pars)
{
throw C4AulExecError(FormatString("script: %s", pErrorMsg ? pErrorMsg->GetCStr() : "(no error)").getData());
throw C4AulExecError(FormatString("script: %s", FnStringFormat(_this, Pars[0].getStr(), &Pars[1], 9).getData()).getData());
}
static bool FnStartCallTrace(C4PropList * _this)
@ -1106,6 +1106,7 @@ C4ScriptFnDef C4ScriptFnMap[]=
{ "EffectCall", true, C4V_Any, { C4V_Object ,C4V_PropList,C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnEffectCall },
{ "Log", true, C4V_Bool, { C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnLog },
{ "DebugLog", true, C4V_Bool, { C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnDebugLog },
{ "FatalError", true, C4V_Nil, { C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnFatalError },
{ "Format", true, C4V_String, { C4V_String ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnFormat },
{ "Trans_Mul", true, C4V_Array, { C4V_Array ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any ,C4V_Any}, FnTrans_Mul},
@ -1169,7 +1170,6 @@ void InitCoreFunctionMap(C4AulScriptEngine *pEngine)
F(SetLength);
F(GetIndexOf);
F(DeepEqual);
F(FatalError);
F(StartCallTrace);
F(StartScriptProfiler);
F(StopScriptProfiler);