From 2d45cf9983f737f9138b1dc0272776ccce4225e1 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sun, 15 Dec 2024 18:46:42 -0600 Subject: [PATCH] Try some better error handling for archive.cpp JSON parsing --- src/archive.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/archive.cpp b/src/archive.cpp index 405ea02..fa5806e 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -99,12 +99,17 @@ void archive::parse_json(const std::string& json_data) { // Process all keys in the JSON object for (auto& [key, value] : data.items()) { - if (json_map.find(key) != json_map.end()) { - json_map[key](value); - json_map.erase(key); - } else if (readonly_map.find(key) != readonly_map.end()) { - readonly_map[key](value); - readonly_map.erase(key); + try { + if (json_map.find(key) != json_map.end()) { + json_map[key](value); + json_map.erase(key); + } else if (readonly_map.find(key) != readonly_map.end()) { + readonly_map[key](value); + readonly_map.erase(key); + } + } catch (const std::exception& e) { + std::cerr << "Unexpected error during JSON parsing: " << e.what() << std::endl; + continue; } }