From 73d3c6f82352430ba8517e8a096f55a3fca879c4 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Mon, 12 Apr 2021 22:19:51 +0000 Subject: [PATCH] Skip modules with parse errors in deserialization --- Core/Registry/AvailableModule.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Core/Registry/AvailableModule.cs b/Core/Registry/AvailableModule.cs index 66ffaa88d1..27b8aea111 100644 --- a/Core/Registry/AvailableModule.cs +++ b/Core/Registry/AvailableModule.cs @@ -9,6 +9,7 @@ using CKAN.Versioning; using log4net; using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; namespace CKAN { @@ -51,6 +52,14 @@ public AvailableModule(string identifier) internal SortedDictionary module_version = new SortedDictionary(); + [OnError] + private void OnError(StreamingContext context, ErrorContext errorContext) + { + log.WarnFormat("Discarding CkanModule, failed to parse {0}: {1}", + errorContext.Path, errorContext.Error.GetBaseException().Message); + errorContext.Handled = true; + } + /// /// Record the given module version as being available. ///