Skip to content

Commit 5814187

Browse files
committed
core: Fix usage of std::to_chars
1 parent 6929e34 commit 5814187

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/text_serializer.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#if __cpp_lib_to_chars >= 201611L
1010
#include <charconv>
11+
#include <stdexcept>
12+
#include <system_error>
1113
#else
1214
#include <cstdio>
1315
#include <limits>
@@ -30,7 +32,8 @@ void WriteValue(std::ostream& out, double value) {
3032
auto [ptr, ec] =
3133
std::to_chars(buffer.data(), buffer.data() + buffer.size(), value);
3234
if (ec != std::errc()) {
33-
throw std::runtime_error("Could not convert double to string: " + ec);
35+
throw std::runtime_error("Could not convert double to string: " +
36+
std::make_error_code(ec).message());
3437
}
3538
out.write(buffer.data(), ptr - buffer.data());
3639
#else

0 commit comments

Comments
 (0)