Skip to content

Commit

Permalink
types: more detailed error message for compiled/parsed unions
Browse files Browse the repository at this point in the history
Upstream says that this code is buggy, and that the assumption that both
compiled and parsed types have the same length is bogous. I guess I
agree with that, but before it gets fixed, let's say what exactly the
C++ bindings dislike.

Change-Id: I4e095ccf4037ae32de76cb8331bba143af9dd01f
  • Loading branch information
jktjkt committed Jan 9, 2024
1 parent 5cc4ee4 commit 419ed47
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ std::vector<Type> Union::types() const
auto types = reinterpret_cast<const lysc_type_union*>(m_type)->types;
std::vector<Type> res;
if (m_typeParsed && LY_ARRAY_COUNT(types) != LY_ARRAY_COUNT(m_typeParsed->types)) {
throw std::logic_error("libyang-cpp internal error: mismatch between the number of types in parsed type.");
throw std::logic_error("libyang-cpp internal error: LY_ARRAY_COUNT(lysc_type_union->types) = "
+ std::to_string(LY_ARRAY_COUNT(types)) + ", LY_ARRAY_COUNT(lysp_type->types) = "
+ std::to_string(LY_ARRAY_COUNT(m_typeParsed->types)) + ", lysp_type->name = " + m_typeParsed->name);
}

for (size_t i = 0; i < LY_ARRAY_COUNT(types); i++) {
Expand Down

0 comments on commit 419ed47

Please sign in to comment.