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:
wraitii
2020-11-15 18:29:17 +00:00
parent 88bc973530
commit 25490bfec3
79 changed files with 810 additions and 667 deletions
+6 -6
View File
@@ -371,7 +371,7 @@ PSRETURN CMapSummaryReader::LoadMap(const VfsPath& pathname)
void CMapSummaryReader::GetMapSettings(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret)
{
ScriptInterface::Request rq(scriptInterface);
ScriptRequest rq(scriptInterface);
ScriptInterface::CreateObject(rq, ret);
@@ -1266,7 +1266,7 @@ int CMapReader::LoadRMSettings()
int CMapReader::GenerateMap()
{
ScriptInterface::Request rq(pSimulation2->GetScriptInterface());
ScriptRequest rq(pSimulation2->GetScriptInterface());
if (!m_MapGen)
{
@@ -1328,7 +1328,7 @@ int CMapReader::GenerateMap()
int CMapReader::ParseTerrain()
{
TIMER(L"ParseTerrain");
ScriptInterface::Request rq(pSimulation2->GetScriptInterface());
ScriptRequest rq(pSimulation2->GetScriptInterface());
// parse terrain from map data
// an error here should stop the loading process
@@ -1403,7 +1403,7 @@ int CMapReader::ParseTerrain()
int CMapReader::ParseEntities()
{
TIMER(L"ParseEntities");
ScriptInterface::Request rq(pSimulation2->GetScriptInterface());
ScriptRequest rq(pSimulation2->GetScriptInterface());
// parse entities from map data
std::vector<Entity> entities;
@@ -1467,7 +1467,7 @@ int CMapReader::ParseEntities()
int CMapReader::ParseEnvironment()
{
// parse environment settings from map data
ScriptInterface::Request rq(pSimulation2->GetScriptInterface());
ScriptRequest rq(pSimulation2->GetScriptInterface());
#define GET_ENVIRONMENT_PROPERTY(val, prop, out)\
if (!pSimulation2->GetScriptInterface().GetProperty(val, #prop, out))\
@@ -1566,7 +1566,7 @@ int CMapReader::ParseEnvironment()
int CMapReader::ParseCamera()
{
ScriptInterface::Request rq(pSimulation2->GetScriptInterface());
ScriptRequest rq(pSimulation2->GetScriptInterface());
// parse camera settings from map data
// defaults if we don't find player starting camera