Skip to content

Commit

Permalink
JSON Parse Error Handling
Browse files Browse the repository at this point in the history
  • Loading branch information
NellsRelo committed Jan 9, 2024
1 parent d05f2e9 commit 1ba06bb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Strings.WARN_LAST_CALL =
"StatsLoaded Complete. Any mods calling the CF API after this point may not appear. Please contact the developer of any missing mods and inform them to switch their CF API call to happen on StatsLoaded instead of on SessionLoaded."
Strings.LATE_LOADER_PREFIX =
"The following mods are attempting to call Compatibility Framework API too late for it to take effect: "
Strings.ERR_CL_NOT_LOADED = "Community Library is required for Compatibility Framework to function."
Strings.ERR_CL_NOT_LOADED = "Community Library is required for Compatibility Framework to function."
Strings.ERR_JSON_PARSE_FAIL = "Couldn't Parse CF JSON Configuration File from "
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ end
---@param modGUID GUIDSTRING
local function TryLoadConfig(configStr, modGUID)
CLUtils.Info("Entering TryLoadConfig")
local data = Ext.Json.Parse(configStr)
if data ~= nil then
SubmitData(data, modGUID)
local success, data = pcall(function ()
return Ext.Json.Parse(configStr)
end)
if success then
if data ~= nil then
SubmitData(data, modGUID)
end
else
CLUtils.Error(Strings.ERR_JSON_PARSE_FAIL .. CLUtils.RetrieveModHandleAndAuthor(modGUID))
end
end

Expand Down
46 changes: 23 additions & 23 deletions CompatibilityFramework/Mods/SubclassCompatibilityFramework/meta.lsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="utf-8"?>
<save>
<version major="4" minor="0" revision="0" build="49"/>
<version major="4" minor="0" revision="0" build="49" />
<region id="Config">
<node id="root">
<children>
<node id="Dependencies"/>
<node id="Dependencies" />
<node id="ModuleInfo">
<attribute id="Author" type="LSWString" value="BG3 Community"/>
<attribute id="CharacterCreationLevelName" type="FixedString" value=""/>
<attribute id="Description" type="LSWString" value="Community-Driven Compatibility API for BG3 Mods"/>
<attribute id="Folder" type="LSWString" value="SubclassCompatibilityFramework"/>
<attribute id="GMTemplate" type="FixedString" value=""/>
<attribute id="LobbyLevelName" type="FixedString" value=""/>
<attribute id="MD5" type="LSString" value=""/>
<attribute id="MainMenuBackgroundVideo" type="FixedString" value=""/>
<attribute id="MenuLevelName" type="FixedString" value=""/>
<attribute id="Name" type="FixedString" value="CompatibilityFramework"/>
<attribute id="NumPlayers" type="uint8" value="4"/>
<attribute id="PhotoBooth" type="FixedString" value=""/>
<attribute id="StartupLevelName" type="FixedString" value=""/>
<attribute id="Tags" type="LSWString" value="Template"/>
<attribute id="Type" type="FixedString" value="Patch"/>
<attribute id="UUID" type="FixedString" value="67fbbd53-7c7d-4cfa-9409-6d737b4d92a9"/>
<attribute id="Version64" type="int64" value="72902025410510854"/>
<attribute id="Author" type="LSWString" value="BG3 Community" />
<attribute id="CharacterCreationLevelName" type="FixedString" value="" />
<attribute id="Description" type="LSWString" value="Community-Driven Compatibility API for BG3 Mods" />
<attribute id="Folder" type="LSWString" value="SubclassCompatibilityFramework" />
<attribute id="GMTemplate" type="FixedString" value="" />
<attribute id="LobbyLevelName" type="FixedString" value="" />
<attribute id="MD5" type="LSString" value="" />
<attribute id="MainMenuBackgroundVideo" type="FixedString" value="" />
<attribute id="MenuLevelName" type="FixedString" value="" />
<attribute id="Name" type="FixedString" value="CompatibilityFramework" />
<attribute id="NumPlayers" type="uint8" value="4" />
<attribute id="PhotoBooth" type="FixedString" value="" />
<attribute id="StartupLevelName" type="FixedString" value="" />
<attribute id="Tags" type="LSWString" value="Template" />
<attribute id="Type" type="FixedString" value="Patch" />
<attribute id="UUID" type="FixedString" value="67fbbd53-7c7d-4cfa-9409-6d737b4d92a9" />
<attribute id="Version64" type="int64" value="72902025410510855" />
<children>
<node id="PublishVersion">
<attribute id="Version64" type="int64" value="72902025410510854"/>
<attribute id="Version64" type="int64" value="72902025410510855" />
</node>
<node id="Scripts" />
<node id="TargetModes">
<children>
<node id="Target">
<attribute id="Object" type="FixedString" value="Story"/>
<attribute id="Object" type="FixedString" value="Story" />
</node>
</children>
</node>
Expand All @@ -40,4 +40,4 @@
</children>
</node>
</region>
</save>
</save>

0 comments on commit 1ba06bb

Please sign in to comment.