From 01770c78db1bcc0dd94daea832611e6cd60e0287 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:40:05 +1100 Subject: [PATCH] Disable stack capture on common Json patching exceptions Speeds up asset loading --- source/core/StarJsonPatch.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/core/StarJsonPatch.cpp b/source/core/StarJsonPatch.cpp index 14505e5..88f9377 100644 --- a/source/core/StarJsonPatch.cpp +++ b/source/core/StarJsonPatch.cpp @@ -12,7 +12,7 @@ Json jsonPatch(Json const& base, JsonArray const& patch) { } return res; } catch (JsonException const& e) { - throw JsonPatchException(strf("Could not apply patch to base. {}", e.what())); + throw JsonPatchException(strf("Could not apply patch to base. {}", e.what()), false); } } @@ -26,7 +26,7 @@ size_t findJsonMatch(Json const& searchable, Json const& value, JsonPath::Pointe return i + 1; } } else { - throw JsonPatchException(strf("Search operation failure, value at '{}' is not an array.", pointer.path())); + throw JsonPatchException(strf("Search operation failure, value at '{}' is not an array.", pointer.path()), false); } return 0; } @@ -49,9 +49,9 @@ namespace JsonPatching { auto operation = op.getString("op"); return JsonPatching::functionMap.get(operation)(base, op); } catch (JsonException const& e) { - throw JsonPatchException(strf("Could not apply operation to base. {}", e.what())); + throw JsonPatchException(strf("Could not apply operation to base. {}", e.what()), false); } catch (MapException const&) { - throw JsonPatchException(strf("Invalid operation: {}", op.getString("op"))); + throw JsonPatchException(strf("Invalid operation: {}", op.getString("op")), false); } } @@ -66,28 +66,28 @@ namespace JsonPatching { auto searchValue = op.get("search"); bool found = findJsonMatch(searchable, searchValue, pointer); if (found && inverseTest) - throw JsonPatchTestFail(strf("Test operation failure, expected {} to be missing.", searchValue)); + throw JsonPatchTestFail(strf("Test operation failure, expected {} to be missing.", searchValue), false); else if (!found && !inverseTest) - throw JsonPatchTestFail(strf("Test operation failure, could not find {}.", searchValue)); + throw JsonPatchTestFail(strf("Test operation failure, could not find {}.", searchValue), false); return base; } else { auto value = op.opt("value"); auto testValue = pointer.get(base); if (!value) { if (inverseTest) - throw JsonPatchTestFail(strf("Test operation failure, expected {} to be missing.", path)); + throw JsonPatchTestFail(strf("Test operation failure, expected {} to be missing.", path), false); return base; } if ((value && (testValue == *value)) ^ inverseTest) return base; else - throw JsonPatchTestFail(strf("Test operation failure, expected {} found {}.", value, testValue)); + throw JsonPatchTestFail(strf("Test operation failure, expected {} found {}.", value, testValue), false); } } catch (JsonPath::TraversalException& e) { if (inverseTest) return base; - throw JsonPatchTestFail(strf("Test operation failure: {}", e.what())); + throw JsonPatchTestFail(strf("Test operation failure: {}", e.what()), false); } }