mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-27 22:33:06 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user