From e41b18d6aee90a3e7c50d580836dc1211e5842ee Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 28 Jun 2023 11:42:33 +0200 Subject: c++,codec-json: Fixed exception handling --- src/codec-json/json.tmpl.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/codec-json/json.tmpl.h b/src/codec-json/json.tmpl.h index 4ef8676..8fb01a9 100644 --- a/src/codec-json/json.tmpl.h +++ b/src/codec-json/json.tmpl.h @@ -459,14 +459,26 @@ struct json_decode { } }; -// The whole std::vector approach is hacky af +template +struct json_decode...>, RootSchema, ToDecode> { + static error_or decode(buffer_view& buff, data...>, ToDecode>& to){ + + return make_error(); + } +}; + +// The whole std::vector approach is hacky af. ToDo change it maybe? template struct json_decode, RootSchema, ToDecode> { template static error_or decode_flat_level(buffer_view& buff, std::vector>& to, std::array& index, std::array& dims, bool log_dim){ if constexpr (Level == D) { json_helper::skip_whitespace(buff); - to.push_back({}); + try { + to.push_back({}); + }catch(std::exception& e){ + return make_error(); + } auto eov = json_decode::decode(buff, to.back()); if(eov.is_error()){ return eov; -- cgit v1.2.3