aboutsummaryrefslogtreecommitdiff
path: root/src/univalue/include/univalue.h
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-07-06 11:46:41 +0200
committerMacroFake <falke.marco@gmail.com>2022-07-13 18:05:39 +0200
commitfa277cd55dd105018e7d1220b4c3d96779e6b0f4 (patch)
tree7b07f6268287e14da3bd5184f40b7975a9459582 /src/univalue/include/univalue.h
parentccccc17b91698aa09ac85f7efea298f3938594ad (diff)
downloadbitcoin-fa277cd55dd105018e7d1220b4c3d96779e6b0f4.tar.xz
univalue: Throw exception on invalid pushes over silent ignore
Diffstat (limited to 'src/univalue/include/univalue.h')
-rw-r--r--src/univalue/include/univalue.h15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h
index 7f9a6aaffd..5cb8268472 100644
--- a/src/univalue/include/univalue.h
+++ b/src/univalue/include/univalue.h
@@ -82,14 +82,14 @@ public:
bool isArray() const { return (typ == VARR); }
bool isObject() const { return (typ == VOBJ); }
- bool push_back(const UniValue& val);
- bool push_backV(const std::vector<UniValue>& vec);
+ void push_back(const UniValue& val);
+ void push_backV(const std::vector<UniValue>& vec);
template <class It>
- bool push_backV(It first, It last);
+ void push_backV(It first, It last);
void __pushKV(const std::string& key, const UniValue& val);
- bool pushKV(const std::string& key, const UniValue& val);
- bool pushKVs(const UniValue& obj);
+ void pushKV(const std::string& key, const UniValue& val);
+ void pushKVs(const UniValue& obj);
std::string write(unsigned int prettyIndent = 0,
unsigned int indentLevel = 0) const;
@@ -140,11 +140,10 @@ public:
};
template <class It>
-bool UniValue::push_backV(It first, It last)
+void UniValue::push_backV(It first, It last)
{
- if (typ != VARR) return false;
+ if (typ != VARR) throw std::runtime_error{"JSON value is not an array as expected"};
values.insert(values.end(), first, last);
- return true;
}
enum jtokentype {