mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Don't terminate on I/O errors in report_error
This commit is contained in:
parent
ef55e74e08
commit
211d312406
@ -174,7 +174,7 @@ FMT_FUNC void format_error_code(internal::buffer<char>& out, int error_code,
|
|||||||
assert(out.size() <= inline_buffer_size);
|
assert(out.size() <= inline_buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// try an fwrite, FMT_THROW on failure
|
// A wrapper around fwrite that throws on error.
|
||||||
FMT_FUNC void fwrite_fully(const void* ptr, size_t size, size_t count,
|
FMT_FUNC void fwrite_fully(const void* ptr, size_t size, size_t count,
|
||||||
FILE* stream) {
|
FILE* stream) {
|
||||||
size_t written = std::fwrite(ptr, size, count, stream);
|
size_t written = std::fwrite(ptr, size, count, stream);
|
||||||
@ -187,9 +187,8 @@ FMT_FUNC void report_error(format_func func, int error_code,
|
|||||||
string_view message) FMT_NOEXCEPT {
|
string_view message) FMT_NOEXCEPT {
|
||||||
memory_buffer full_message;
|
memory_buffer full_message;
|
||||||
func(full_message, error_code, message);
|
func(full_message, error_code, message);
|
||||||
// Use Writer::data instead of Writer::c_str to avoid potential memory
|
// Don't use fwrite_fully because the latter may throw.
|
||||||
// allocation.
|
(void)std::fwrite(full_message.data(), full_message.size(), 1, stderr);
|
||||||
fwrite_fully(full_message.data(), 1, full_message.size(), stderr);
|
|
||||||
std::fputc('\n', stderr);
|
std::fputc('\n', stderr);
|
||||||
}
|
}
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
Loading…
Reference in New Issue
Block a user