Skip to content

Commit

Permalink
[RequestLib] Added better error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
kafeijao committed Jun 18, 2024
1 parent d94e56f commit ae60f00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions RequestLib/ModNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,12 @@ private static void OnResponse(string senderGuid, string possibleResponseGuid, b
var pendingRequestGuid = responseGuid.ToString(GuidFormat);
if (PendingRequests.Remove(pendingRequestGuid, out var request)) {
var response = new API.Response(accepted ? API.RequestResult.Accepted : API.RequestResult.Declined, responseMetadata);
request.OnResponse?.Invoke(request, response);
try {
request.OnResponse?.Invoke(request, response);
}
catch (Exception e) {
MelonLogger.Error($"The response handler function has errored. This is a problem with the mod {request.ModName}", e);
}
}
}

Expand Down Expand Up @@ -354,9 +359,10 @@ private static void OnMessage(object _, MessageReceivedEventArgs e) {
break;
}
}
catch (Exception) {
catch (Exception ex) {
MelonLogger.Warning($"Received a malformed message from {CVRPlayerManager.Instance.TryGetPlayerName(senderGuid)}, " +
$"they might be running an outdated version of the mod, or I broke something, or they're trying to do something funny.");
MelonLogger.Error(ex);
}
}

Expand Down
2 changes: 1 addition & 1 deletion RequestLib/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace Kafe.RequestLib.Properties;
internal static class AssemblyInfoParams {
public const string Version = "0.0.12";
public const string Version = "0.0.13";
public const string Author = "kafeijao";
public const string BTKUILibName = "BTKUILib";
public const string BTKSAImmersiveHudName = "BTKSAImmersiveHud";
Expand Down
4 changes: 2 additions & 2 deletions RequestLib/Properties/CVRMG.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_id": 169,
"name": "RequestLib",
"modversion": "0.0.12",
"modversion": "0.0.13",
"gameversion": "2024r175",
"loaderversion": "v0.6.1",
"modtype": "Mod",
Expand All @@ -14,6 +14,6 @@
"requirements": ["[BTKUILib](https://api.cvrmg.com/v1/mods/download/113)"],
"downloadlink": "https://github.com/kafeijao/Kafe_CVR_Mods/releases/download/r68/RequestLib.dll",
"sourcelink": "https://github.com/kafeijao/Kafe_CVR_Mods/tree/master/RequestLib",
"changelog": "- Added a listener on the receiver of the request when the response is about to get sent. This is useful when you want to do something with the request result (since auto-accept/decline exist you wouldn't be able to intercept those without this)",
"changelog": "- Added better error logging",
"embedcolor": "16C60C"
}

0 comments on commit ae60f00

Please sign in to comment.