diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-03-24 20:25:22 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-04-02 15:30:03 +0200 |
commit | c2c3ca4b17122f5e93001b26330e97fb00f6c7f3 (patch) | |
tree | 6a78cb35669bf03206e2945e4ac397793405261d /src | |
parent | 8a0b8d3b0fcde046810eba5373649616c88d44da (diff) | |
download | justbuild-c2c3ca4b17122f5e93001b26330e97fb00f6c7f3.tar.gz |
LargeObjectCAS: Implement auxiliary class for storing error information.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/storage/large_object_cas.hpp | 31 | ||||
-rw-r--r-- | src/buildtool/storage/large_object_cas.tpp | 1 |
2 files changed, 31 insertions, 1 deletions
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 <filesystem> #include <optional> +#include <string> +#include <utility> #include <vector> #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 <cstdint> #include <cstdlib> #include <fstream> -#include <string> #include "nlohmann/json.hpp" #include "src/buildtool/compatibility/native_support.hpp" |