diff options
| author | Dan Engelbrecht <[email protected]> | 2023-08-01 08:51:18 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-01 08:51:18 +0200 |
| commit | d7419eb4901ec589a5dcec683b8dc052bd6d896e (patch) | |
| tree | c1b52e427c380363315c64f350ba45ab7a9693ae /src/zenserver/projectstore/fileremoteprojectstore.cpp | |
| parent | catch exceptions when scheduling GC and when writing GC scheduling state (#339) (diff) | |
| download | zen-d7419eb4901ec589a5dcec683b8dc052bd6d896e.tar.xz zen-d7419eb4901ec589a5dcec683b8dc052bd6d896e.zip | |
add requested item in oplog remote op (#340)
* add more context for oplog import/export errors
Diffstat (limited to 'src/zenserver/projectstore/fileremoteprojectstore.cpp')
| -rw-r--r-- | src/zenserver/projectstore/fileremoteprojectstore.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/zenserver/projectstore/fileremoteprojectstore.cpp b/src/zenserver/projectstore/fileremoteprojectstore.cpp index d7a34a6c2..1279a294b 100644 --- a/src/zenserver/projectstore/fileremoteprojectstore.cpp +++ b/src/zenserver/projectstore/fileremoteprojectstore.cpp @@ -60,17 +60,24 @@ public: std::filesystem::path ContainerPath = m_OutputPath; ContainerPath.append(m_Name); - CreateDirectories(m_OutputPath); - BasicFile ContainerFile; - ContainerFile.Open(ContainerPath, BasicFile::Mode::kTruncate); - std::error_code Ec; - ContainerFile.WriteAll(Payload, Ec); - if (Ec) + try + { + CreateDirectories(m_OutputPath); + BasicFile ContainerFile; + ContainerFile.Open(ContainerPath, BasicFile::Mode::kTruncate); + std::error_code Ec; + ContainerFile.WriteAll(Payload, Ec); + if (Ec) + { + throw std::system_error(Ec, Ec.message()); + } + Result.RawHash = IoHash::HashBuffer(Payload); + } + catch (std::exception& Ex) { Result.ErrorCode = gsl::narrow<int32_t>(HttpResponseCode::InternalServerError); - Result.Reason = Ec.message(); + Result.Reason = fmt::format("Failed saving oplog container to '{}'. Reason: {}", ContainerPath, Ex.what()); } - Result.RawHash = IoHash::HashBuffer(Payload); Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500; return Result; } @@ -98,7 +105,7 @@ public: catch (std::exception& Ex) { Result.ErrorCode = gsl::narrow<int32_t>(HttpResponseCode::InternalServerError); - Result.Reason = Ex.what(); + Result.Reason = fmt::format("Failed saving oplog attachment to '{}'. Reason: {}", ChunkPath, Ex.what()); } } Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500; @@ -134,8 +141,9 @@ public: ContainerPath.append(m_Name); if (!std::filesystem::is_regular_file(ContainerPath)) { - Result.ErrorCode = gsl::narrow<int>(HttpResponseCode::NotFound); - Result.Reason = fmt::format("The file {} does not exist"sv, ContainerPath.string()); + Result.ErrorCode = gsl::narrow<int>(HttpResponseCode::NotFound); + Result.Reason = + fmt::format("Failed loading oplog container from '{}'. Reason: 'The file does not exist'", ContainerPath.string()); Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500; return Result; } @@ -149,7 +157,7 @@ public: if (!Result.ContainerObject) { Result.ErrorCode = gsl::narrow<int32_t>(HttpResponseCode::InternalServerError); - Result.Reason = fmt::format("The file {} is not formatted as a compact binary object"sv, ContainerPath.string()); + Result.Reason = fmt::format("The file {} is not formatted as a compact binary object", ContainerPath.string()); Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500; return Result; } @@ -163,8 +171,8 @@ public: std::filesystem::path ChunkPath = GetAttachmentPath(RawHash); if (!std::filesystem::is_regular_file(ChunkPath)) { - Result.ErrorCode = gsl::narrow<int>(HttpResponseCode::NotFound); - Result.Reason = fmt::format("The file {} does not exist"sv, ChunkPath.string()); + Result.ErrorCode = gsl::narrow<int>(HttpResponseCode::NotFound); + Result.Reason = fmt::format("Failed loading oplog attachment from '{}'. Reason: 'The file does not exist'", ChunkPath.string()); Result.ElapsedSeconds = Timer.GetElapsedTimeMs() / 1000.500; return Result; } |