-
-
Notifications
You must be signed in to change notification settings - Fork 7k
use diagnostic positions in exceptions #4585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b615508
add a ci step for Json_Diagnostic_Positions
hnampally 39434ce
Update ci.cmake to address review comments
hnampally c78941a
address review comment
hnampally 66de11c
fix typo in the comment
hnampally ffbc778
fix typos in ci.cmake
hnampally c1e8021
invoke the new ci step from ubuntu.yml
hnampally 05f8bb5
Merge branch 'nlohmann:develop' into develop
hnampally 3070676
issue4561 - use diagnostic positions for exceptions
hnampally 75af9a8
fix ci_test_documentation check
hnampally e302058
address review comments
hnampally 482ecf3
fix ci check failures for unit-diagnostic-postions.cpp
hnampally 7bc339f
improvements based on review comments
hnampally ff322a3
fix const correctness string
hnampally 160de4a
further refinements based on reviews
hnampally 8442316
add one more test case for full coverage
hnampally 903225e
ci check fix - add const
hnampally 73a3f30
Merge branch 'nlohmann:develop' into develop
hnampally f0e5325
add unit tests for json_diagnostic_postions only
hnampally 4b47617
fix ci_test_diagnostics
hnampally b3af659
Merge branch 'nlohmann:develop' into develop
hnampally 5c22738
fix ci_test_build_documentation check
hnampally File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <iostream> | ||
|
||
#define JSON_DIAGNOSTIC_POSITIONS 1 | ||
#include <nlohmann/json.hpp> | ||
|
||
using json = nlohmann::json; | ||
|
||
/* Demonstration of type error exception with diagnostic postions support enabled */ | ||
int main() | ||
{ | ||
//Invalid json string - housenumber type must be int instead of string | ||
std::string json_invalid_string = R"( | ||
{ | ||
"address": { | ||
"street": "Fake Street", | ||
"housenumber": "1" | ||
} | ||
} | ||
)"; | ||
json j = json::parse(json_invalid_string); | ||
try | ||
{ | ||
int housenumber = j["address"]["housenumber"]; | ||
} | ||
catch (const json::exception& e) | ||
{ | ||
std::cout << e.what() << '\n'; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[json.exception.type_error.302] (bytes 92-95) type must be number, but is string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <iostream> | ||
|
||
#define JSON_DIAGNOSTICS 1 | ||
#define JSON_DIAGNOSTIC_POSITIONS 1 | ||
#include <nlohmann/json.hpp> | ||
|
||
using json = nlohmann::json; | ||
|
||
/* Demonstration of type error exception with diagnostic postions support enabled */ | ||
int main() | ||
{ | ||
//Invalid json string - housenumber type must be int instead of string | ||
std::string json_invalid_string = R"( | ||
{ | ||
"address": { | ||
"street": "Fake Street", | ||
"housenumber": "1" | ||
} | ||
} | ||
)"; | ||
json j = json::parse(json_invalid_string); | ||
try | ||
{ | ||
int housenumber = j["address"]["housenumber"]; | ||
hnampally marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
catch (const json::exception& e) | ||
{ | ||
std::cout << e.what() << '\n'; | ||
} | ||
} | ||
nlohmann marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[json.exception.type_error.302] (/address/housenumber) (bytes 92-95) type must be number, but is string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.