Replace ScriptException::Raise in Engine functions

Now exceptions can be thrown. The function throwing exceptions becomes
cleaner and doesn't require a `ScriptRequest` anymore.
This commit is contained in:
phosit
2025-06-18 08:16:42 +02:00
committed by Phosit
parent 616fa4a006
commit 9822a22573
9 changed files with 87 additions and 106 deletions
+5 -3
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2023 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -26,6 +26,8 @@
#include "scriptinterface/Object.h"
#include "scriptinterface/ScriptConversions.h"
#include <stdexcept>
extern void RestartEngine();
// To avoid copying data needlessly in GetEngineInfo, implement a ToJSVal for pointer types.
@@ -137,8 +139,8 @@ JS::Value GetAvailableMods(const ScriptRequest& rq)
JS::RootedValue json(rq.cx);
if (!Script::ParseJSON(rq, data.m_Text, &json))
{
ScriptException::Raise(rq, "Error parsing mod.json of '%s'", data.m_Pathname.c_str());
continue;
throw std::runtime_error{fmt::format("Error parsing mod.json of '{}'",
data.m_Pathname.c_str())};
}
Script::SetProperty(rq, ret, data.m_Pathname.c_str(), json);
}