Skip to content

Commit 38130ae

Browse files
authored
Merge pull request #453 from jupp0r/fix-std-tochars
core: Fix usage of std::to_chars
2 parents af84494 + 5814187 commit 38130ae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if(POLICY CMP0091)
44
cmake_policy(SET CMP0091 NEW) # recognize CMAKE_MSVC_RUNTIME_LIBRARY
55
endif()
66

7-
project(prometheus-cpp VERSION 0.12.0)
7+
project(prometheus-cpp VERSION 0.12.1)
88

99
include(GenerateExportHeader)
1010
include(GNUInstallDirs)

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)