Commit d4b9778f authored by Aleksandr Sasha Sergeev's avatar Aleksandr Sasha Sergeev Committed by Facebook GitHub Bot

Use different parse errors for NaN and INF double values.

Summary: To facilitate debugging of T88337980

Reviewed By: rdavies

Differential Revision: D27610329

fbshipit-source-id: 6b01af24e2cfdda9afcbef10d2951ac071d2fd10
parent 6ea76266
......@@ -61,11 +61,15 @@ struct Printer {
void operator()(dynamic const& v) const {
switch (v.type()) {
case dynamic::DOUBLE:
if (!opts_.allow_nan_inf &&
(std::isnan(v.asDouble()) || std::isinf(v.asDouble()))) {
throw json::parse_error(
"folly::toJson: JSON object value was a "
"NaN or INF");
if (!opts_.allow_nan_inf) {
if (std::isnan(v.asDouble())) {
throw json::parse_error(
"folly::toJson: JSON object value was a NaN");
}
if (std::isinf(v.asDouble())) {
throw json::parse_error(
"folly::toJson: JSON object value was an INF");
}
}
toAppend(
v.asDouble(), &out_, opts_.double_mode, opts_.double_num_digits);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment