mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 01:04:06 +00:00
Improve JS Exception handling.
- Check for pending exceptions after function calls and script executions. - Call LOGERROR instead of JS_ReportError when there is a conversion error in FromJSVal, since that can only be called from C++ (where JS errors don't really make sense). Instead, C++ callers of FromJSVal should handle the failure and, themselves, either report an error or simply do something else. - Wrap JS_ReportError since that makes updating it later easier. This isn't a systematical fix since ToJSVal also ought return a boolean for failures, and we probably should trigger errors instead of warnings on 'implicit' conversions, rather a preparation diff. Part of the SM52 migration, stage: SM45 compatible (actually SM52 incompatible, too). Based on a patch by: Itms Comments by: Vladislavbelov, Stan` Refs #742, #4893 Differential Revision: https://code.wildfiregames.com/D3093 This was SVN commit r24187.
This commit is contained in:
+3
-3
@@ -191,7 +191,7 @@ bool CGame::StartVisualReplay(const OsPath& replayPath)
|
||||
std::getline(*m_ReplayStream, line);
|
||||
|
||||
const ScriptInterface& scriptInterface = m_Simulation2->GetScriptInterface();
|
||||
ScriptInterface::Request rq(scriptInterface);
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
JS::RootedValue attribs(rq.cx);
|
||||
scriptInterface.ParseJSON(line, &attribs);
|
||||
@@ -208,7 +208,7 @@ bool CGame::StartVisualReplay(const OsPath& replayPath)
|
||||
void CGame::RegisterInit(const JS::HandleValue attribs, const std::string& savedState)
|
||||
{
|
||||
const ScriptInterface& scriptInterface = m_Simulation2->GetScriptInterface();
|
||||
ScriptInterface::Request rq(scriptInterface);
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
m_InitialSavedState = savedState;
|
||||
m_IsSavedGame = !savedState.empty();
|
||||
@@ -323,7 +323,7 @@ PSRETURN CGame::ReallyStartGame()
|
||||
if (g_GUI && g_GUI->GetPageCount())
|
||||
{
|
||||
shared_ptr<ScriptInterface> scriptInterface = g_GUI->GetActiveGUI()->GetScriptInterface();
|
||||
ScriptInterface::Request rq(scriptInterface);
|
||||
ScriptRequest rq(scriptInterface);
|
||||
|
||||
JS::RootedValue global(rq.cx, rq.globalValue());
|
||||
if (scriptInterface->HasProperty(global, "reallyStartGame"))
|
||||
|
||||
Reference in New Issue
Block a user