From c2c3ca4b17122f5e93001b26330e97fb00f6c7f3 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Sun, 24 Mar 2024 20:25:22 +0100 Subject: LargeObjectCAS: Implement auxiliary class for storing error information. --- src/buildtool/storage/large_object_cas.hpp | 31 ++++++++++++++++++++++++++++++ src/buildtool/storage/large_object_cas.tpp | 1 - 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/buildtool/storage/large_object_cas.hpp b/src/buildtool/storage/large_object_cas.hpp index a1a93606..881acc15 100644 --- a/src/buildtool/storage/large_object_cas.hpp +++ b/src/buildtool/storage/large_object_cas.hpp @@ -17,12 +17,43 @@ #include #include +#include +#include #include #include "src/buildtool/common/bazel_types.hpp" #include "src/buildtool/file_system/file_storage.hpp" #include "src/buildtool/file_system/object_type.hpp" +enum class LargeObjectErrorCode { + /// \brief An internal error occured. + Internal = 0, + + /// \brief The digest is not in the CAS. + FileNotFound, +}; + +/// \brief Describes an error that occurred during split-splice. +class LargeObjectError final { + public: + LargeObjectError(LargeObjectErrorCode code, std::string message) + : code_(code), message_(std::move(message)) {} + + /// \brief Obtain the error code. + [[nodiscard]] auto Code() const noexcept -> LargeObjectErrorCode { + return code_; + } + + /// \brief Obtain the error message. + [[nodiscard]] auto Message() && noexcept -> std::string { + return std::move(message_); + } + + private: + LargeObjectErrorCode const code_; + std::string message_; +}; + /// \brief Stores auxiliary information for reconstructing large objects. /// The entries are keyed by the hash of the spliced result and the value of an /// entry is the concatenation of the hashes of chunks the large object is diff --git a/src/buildtool/storage/large_object_cas.tpp b/src/buildtool/storage/large_object_cas.tpp index 12894992..d5228c72 100644 --- a/src/buildtool/storage/large_object_cas.tpp +++ b/src/buildtool/storage/large_object_cas.tpp @@ -18,7 +18,6 @@ #include #include #include -#include #include "nlohmann/json.hpp" #include "src/buildtool/compatibility/native_support.hpp" -- cgit v1.2.3