From e8fbd606e8ef150984e798a39727394675483a41 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sun, 15 Dec 2024 18:53:03 -0600 Subject: [PATCH] Apply error handling more universally --- src/archive.cpp | 1 - src/build.cpp | 10 +++++++--- src/distribution.cpp | 10 +++++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/archive.cpp b/src/archive.cpp index fa5806e..3468708 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -108,7 +108,6 @@ void archive::parse_json(const std::string& json_data) { readonly_map.erase(key); } } catch (const std::exception& e) { - std::cerr << "Unexpected error during JSON parsing: " << e.what() << std::endl; continue; } } diff --git a/src/build.cpp b/src/build.cpp index e1c7f6e..401729a 100644 --- a/src/build.cpp +++ b/src/build.cpp @@ -68,9 +68,13 @@ void build::parse_json(const std::string& json_data) { // Process JSON keys for (auto& [key, value] : data.items()) { - if (json_map.find(key) != json_map.end()) { - json_map[key](value); - json_map.erase(key); + try { + if (json_map.find(key) != json_map.end()) { + json_map[key](value); + json_map.erase(key); + } + } catch (...) { + continue; } } } catch (...) { diff --git a/src/distribution.cpp b/src/distribution.cpp index 83efc4f..feabb77 100644 --- a/src/distribution.cpp +++ b/src/distribution.cpp @@ -53,9 +53,13 @@ void distribution::parse_json(const std::string& json_data) { // Process JSON keys dynamically for (auto& [key, value] : data.items()) { - if (json_map.find(key) != json_map.end()) { - json_map[key](value); - json_map.erase(key); + try { + if (json_map.find(key) != json_map.end()) { + json_map[key](value); + json_map.erase(key); + } + } catch (...) { + continue; } } } catch (const nlohmann::json::parse_error& e) {