Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Jan 23, 2022
1 parent 7749566 commit 8304f0d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/jsoncons/decode_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ namespace jsoncons {
while (cursor.current().event_type() != staj_event_type::end_array && !ec)
{
v.push_back(decode_traits<value_type,CharT>::decode(cursor, decoder, ec));
if (ec) {return T{};}
cursor.next(ec);
}
return v;
Expand Down Expand Up @@ -419,7 +420,9 @@ namespace jsoncons {
while (cursor.current().event_type() != staj_event_type::end_array && !ec)
{
v.insert(decode_traits<value_type,CharT>::decode(cursor, decoder, ec));
if (ec) {return T{};}
cursor.next(ec);
if (ec) {return T{};}
}
return v;
}
Expand Down Expand Up @@ -454,7 +457,9 @@ namespace jsoncons {
for (std::size_t i = 0; i < N && cursor.current().event_type() != staj_event_type::end_array && !ec; ++i)
{
v[i] = decode_traits<value_type,CharT>::decode(cursor, decoder, ec);
if (ec) {return T{};}
cursor.next(ec);
if (ec) {return T{};}
}
return v;
}
Expand Down Expand Up @@ -498,7 +503,9 @@ namespace jsoncons {
cursor.next(ec);
if (ec) return val;
val.emplace(std::move(key),decode_traits<mapped_type,CharT>::decode(cursor, decoder, ec));
if (ec) {return val;}
cursor.next(ec);
if (ec) {return val;}
}
return val;
}
Expand Down Expand Up @@ -547,7 +554,9 @@ namespace jsoncons {
cursor.next(ec);
if (ec) return val;
val.emplace(n, decode_traits<mapped_type,CharT>::decode(cursor, decoder, ec));
if (ec) {return val;}
cursor.next(ec);
if (ec) {return val;}
}
return val;
}
Expand Down

0 comments on commit 8304f0d

Please sign in to comment.