From 3b95585ecc08e26eded7fea4d61d4b092f5fbd2d Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 11 May 2021 18:36:30 +0200 Subject: Added paths as context to I/O error exception messages --- zenstore/caslog.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'zenstore/caslog.cpp') diff --git a/zenstore/caslog.cpp b/zenstore/caslog.cpp index 0f918bfd8..6d9e22f88 100644 --- a/zenstore/caslog.cpp +++ b/zenstore/caslog.cpp @@ -5,6 +5,8 @@ #include "CompactCas.h" #include +#include +#include #include #include #include @@ -12,6 +14,7 @@ #include +#include #include #include @@ -24,6 +27,8 @@ struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax erro namespace zen { +using namespace fmt::literals; + uint32_t CasLogFile::FileHeader::ComputeChecksum() { @@ -49,7 +54,7 @@ CasLogFile::Open(std::filesystem::path FileName, size_t RecordSize, bool IsCreat if (FAILED(hRes)) { - throw std::system_error(GetLastError(), std::system_category(), "Failed to open log file" /* TODO: add path */); + throw std::system_error(GetLastError(), std::system_category(), "Failed to open log file '{}'"_format(FileName)); } uint64_t AppendOffset = 0; @@ -135,7 +140,7 @@ CasLogFile::Append(const void* DataPointer, uint64_t DataSize) if (FAILED(hRes)) { - throw std::system_error(GetLastError(), std::system_category(), "Failed to write to log file" /* TODO: add context */); + throw std::system_error(GetLastError(), std::system_category(), "Failed to write to log file '{}'"_format(zen::PathFromHandle(m_File))); } } @@ -156,7 +161,7 @@ CasBlobFile::Open(std::filesystem::path FileName, bool isCreate) if (FAILED(hRes)) { - throw std::system_error(GetLastError(), std::system_category(), "Failed to open bucket sobs file"); + throw std::system_error(GetLastError(), std::system_category(), "Failed to open bucket sobs file '{}'"_format(FileName)); } } @@ -172,7 +177,7 @@ CasBlobFile::Read(void* Data, uint64_t Size, uint64_t Offset) if (FAILED(hRes)) { - throw std::system_error(GetLastError(), std::system_category(), "Failed to read from file" /* TODO: add context */); + throw std::system_error(GetLastError(), std::system_category(), "Failed to read from file '{}'"_format(zen::PathFromHandle(m_File))); } } @@ -198,7 +203,7 @@ CasBlobFile::Write(const void* Data, uint64_t Size, uint64_t Offset) if (FAILED(hRes)) { - throw std::system_error(GetLastError(), std::system_category(), "Failed to write to file" /* TODO: add context */); + throw std::system_error(GetLastError(), std::system_category(), "Failed to write to file '{}'"_format(zen::PathFromHandle(m_File))); } } -- cgit v1.2.3