Skip to content

feat: improve type assertion messages with actual ValueType#1686

Merged
baylesj merged 2 commits into
masterfrom
fix-issue-1627
May 14, 2026
Merged

feat: improve type assertion messages with actual ValueType#1686
baylesj merged 2 commits into
masterfrom
fix-issue-1627

Conversation

@baylesj
Copy link
Copy Markdown
Contributor

@baylesj baylesj commented May 14, 2026

When interacting with a Json::Value, numerous assertions correctly check that the value is of an expected type (e.g., an object or array) before accessing it. If there is a mismatch, the error is somewhat confusing as it only says "requires objectValue".

This commit improves the assertion messages by introducing a valueTypeToString helper, allowing the assertions to report the actual ValueType encountered (e.g., "requires objectValue, but found stringValue"). This will significantly streamline debugging for users experiencing type mismatch errors.

Fixes #1627

baylesj added 2 commits May 14, 2026 16:08
When indexing into a Json::Value, several assertions check that the value is an object or array. This commit enhances the error messages by reporting the actual type found, making it easier for users to debug type mismatch issues.

Fixes #1627
@coveralls
Copy link
Copy Markdown

coveralls commented May 14, 2026

Coverage Report for CI Build 25890872676

Coverage decreased (-0.2%) to 89.944%

Details

  • Coverage decreased (-0.2%) from the base build.
  • Patch coverage: 7 uncovered changes across 1 file (13 of 20 lines covered, 65.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/lib_json/json_value.cpp 20 13 65.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 2726
Covered Lines: 2602
Line Coverage: 95.45%
Relevant Branches: 2614
Covered Branches: 2201
Branch Coverage: 84.2%
Branches in Coverage %: Yes
Coverage Strength: 23434.91 hits per line

💛 - Coveralls

@baylesj baylesj merged commit d4d0721 into master May 14, 2026
48 checks passed
@baylesj baylesj deleted the fix-issue-1627 branch May 14, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

not use jsoncpp api but throw "in Json::Value::resolveReference(key, end): requires objectValue " error

2 participants