diff options
author | Josh Lehan <krellan@google.com> | 2022-03-04 05:25:55 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-03-12 21:17:22 +0300 |
commit | c5114a57c5460916141260b5d31680f82fdda324 (patch) | |
tree | dd78a6d266fe469f0a50ce337e252c72a82452f8 /COMMON_ERRORS.md | |
parent | f7725d79fa9b5fcffcc368008fa029ea1a16c4b9 (diff) | |
download | bmcweb-c5114a57c5460916141260b5d31680f82fdda324.tar.xz |
Updated text to elaborate on JSON exceptions
Mentioning operator<< and operator>> as throwing
Noting preferred usage of parse() and dump()
Signed-off-by: Josh Lehan <krellan@google.com>
Change-Id: I1ffdc4b39e518ec348a553eac5080accf75fae8e
Diffstat (limited to 'COMMON_ERRORS.md')
-rw-r--r-- | COMMON_ERRORS.md | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/COMMON_ERRORS.md b/COMMON_ERRORS.md index 7e6d26cbf6..6bb5c05155 100644 --- a/COMMON_ERRORS.md +++ b/COMMON_ERRORS.md @@ -72,6 +72,8 @@ Commonly used methods that fall into this pattern: - nlohmann::json::get - nlohmann::json::get\_ref - nlohmann::json::get\_to +- nlohmann::json::operator\<\< +- nlohmann::json::operator\>\> - std::filesystem::create\_directory - std::filesystem::rename - std::filesystem::file\_size @@ -79,12 +81,18 @@ Commonly used methods that fall into this pattern: - std::stol - std::stoll -#### special/strange case: +#### Special note: JSON -nlohmann::json::parse by default throws on failure, but also accepts a optional -argument that causes it to not throw. Please consult the other examples in the -code for how to handle errors. +`nlohmann::json::parse` by default +[throws](https://json.nlohmann.me/api/basic_json/parse/) on failure, but +also accepts an optional argument that causes it to not throw: set the 3rd +argument to `false`. +`nlohmann::json::dump` by default +[throws](https://json.nlohmann.me/api/basic_json/dump/) on failure, but also +accepts an optional argument that causes it to not throw: set the 4th +argument to `replace`. Although `ignore` preserves content 1:1, `replace` +is preferred from a security point of view. #### Special note: Boost there is a whole class of boost asio functions that provide both a method that |