summaryrefslogtreecommitdiff
path: root/src/buildtool/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/common')
-rw-r--r--src/buildtool/common/action_description.hpp2
-rw-r--r--src/buildtool/common/artifact.hpp2
-rw-r--r--src/buildtool/common/artifact_description.cpp64
-rw-r--r--src/buildtool/common/artifact_description.hpp2
4 files changed, 30 insertions, 40 deletions
diff --git a/src/buildtool/common/action_description.hpp b/src/buildtool/common/action_description.hpp
index f4756688..e51552ad 100644
--- a/src/buildtool/common/action_description.hpp
+++ b/src/buildtool/common/action_description.hpp
@@ -196,7 +196,7 @@ class ActionDescription {
return action_.Id();
}
- [[nodiscard]] auto ToJson() const noexcept -> nlohmann::json {
+ [[nodiscard]] auto ToJson() const -> nlohmann::json {
auto json = nlohmann::json{{"command", action_.Command()}};
if (not output_files_.empty()) {
json["output"] = output_files_;
diff --git a/src/buildtool/common/artifact.hpp b/src/buildtool/common/artifact.hpp
index a933433e..1ef169d3 100644
--- a/src/buildtool/common/artifact.hpp
+++ b/src/buildtool/common/artifact.hpp
@@ -64,7 +64,7 @@ class Artifact {
// Create JSON of the form '{"id": "hash", "size": x, "file_type": "f"}'
// As the failed property is only internal to a run, discard it.
- [[nodiscard]] auto ToJson() const noexcept -> nlohmann::json {
+ [[nodiscard]] auto ToJson() const -> nlohmann::json {
return {{"id", digest.hash()},
{"size", digest.size()},
{"file_type", std::string{ToChar(type)}}};
diff --git a/src/buildtool/common/artifact_description.cpp b/src/buildtool/common/artifact_description.cpp
index e5a67155..b1451491 100644
--- a/src/buildtool/common/artifact_description.cpp
+++ b/src/buildtool/common/artifact_description.cpp
@@ -24,19 +24,19 @@
namespace {
[[nodiscard]] auto DescribeLocalArtifact(std::filesystem::path const& src_path,
- std::string const& repository) noexcept
+ std::string const& repository)
-> nlohmann::json;
-[[nodiscard]] auto DescribeKnownArtifact(
- std::string const& blob_id,
- std::size_t size,
- ObjectType type = ObjectType::File) noexcept -> nlohmann::json;
+[[nodiscard]] auto DescribeKnownArtifact(std::string const& blob_id,
+ std::size_t size,
+ ObjectType type = ObjectType::File)
+ -> nlohmann::json;
[[nodiscard]] auto DescribeActionArtifact(std::string const& action_id,
- std::string const& out_path) noexcept
+ std::string const& out_path)
-> nlohmann::json;
-[[nodiscard]] auto DescribeTreeArtifact(std::string const& tree_id) noexcept
+[[nodiscard]] auto DescribeTreeArtifact(std::string const& tree_id)
-> nlohmann::json;
[[nodiscard]] auto CreateLocalArtifactDescription(nlohmann::json const& data)
@@ -129,30 +129,23 @@ auto ArtifactDescription::FromJson(HashFunction::Type hash_type,
return std::nullopt;
}
-auto ArtifactDescription::ToJson() const noexcept -> nlohmann::json {
- try {
- if (std::holds_alternative<Local>(data_)) {
- auto const& [path, repo] = std::get<Local>(data_);
- return DescribeLocalArtifact(path.string(), repo);
- }
- if (std::holds_alternative<Known>(data_)) {
- auto const& [digest, file_type, _] = std::get<Known>(data_);
- return DescribeKnownArtifact(
- digest.hash(), digest.size(), file_type);
- }
- if (std::holds_alternative<Action>(data_)) {
- auto const& [action_id, path] = std::get<Action>(data_);
- return DescribeActionArtifact(action_id, path);
- }
- if (std::holds_alternative<Tree>(data_)) {
- return DescribeTreeArtifact(std::get<Tree>(data_));
- }
- Logger::Log(LogLevel::Error, "Internal error, unknown artifact type");
- } catch (std::exception const& ex) {
- Logger::Log(LogLevel::Error,
- "Serializing to JSON failed with error:\n{}",
- ex.what());
+auto ArtifactDescription::ToJson() const -> nlohmann::json {
+ if (std::holds_alternative<Local>(data_)) {
+ auto const& [path, repo] = std::get<Local>(data_);
+ return DescribeLocalArtifact(path.string(), repo);
+ }
+ if (std::holds_alternative<Known>(data_)) {
+ auto const& [digest, file_type, _] = std::get<Known>(data_);
+ return DescribeKnownArtifact(digest.hash(), digest.size(), file_type);
+ }
+ if (std::holds_alternative<Action>(data_)) {
+ auto const& [action_id, path] = std::get<Action>(data_);
+ return DescribeActionArtifact(action_id, path);
+ }
+ if (std::holds_alternative<Tree>(data_)) {
+ return DescribeTreeArtifact(std::get<Tree>(data_));
}
+ Logger::Log(LogLevel::Error, "Internal error, unknown artifact type");
Ensures(false); // unreachable
return {};
}
@@ -210,8 +203,7 @@ auto ArtifactDescription::ComputeId(nlohmann::json const& desc) noexcept
namespace {
auto DescribeLocalArtifact(std::filesystem::path const& src_path,
- std::string const& repository) noexcept
- -> nlohmann::json {
+ std::string const& repository) -> nlohmann::json {
return {
{"type", "LOCAL"},
{"data", {{"path", src_path.string()}, {"repository", repository}}}};
@@ -219,7 +211,7 @@ auto DescribeLocalArtifact(std::filesystem::path const& src_path,
auto DescribeKnownArtifact(std::string const& blob_id,
std::size_t size,
- ObjectType type) noexcept -> nlohmann::json {
+ ObjectType type) -> nlohmann::json {
std::string const typestr{ToChar(type)};
return {
{"type", "KNOWN"},
@@ -227,14 +219,12 @@ auto DescribeKnownArtifact(std::string const& blob_id,
}
auto DescribeActionArtifact(std::string const& action_id,
- std::string const& out_path) noexcept
- -> nlohmann::json {
+ std::string const& out_path) -> nlohmann::json {
return {{"type", "ACTION"},
{"data", {{"id", action_id}, {"path", out_path}}}};
}
-auto DescribeTreeArtifact(std::string const& tree_id) noexcept
- -> nlohmann::json {
+auto DescribeTreeArtifact(std::string const& tree_id) -> nlohmann::json {
return {{"type", "TREE"}, {"data", {{"id", tree_id}}}};
}
diff --git a/src/buildtool/common/artifact_description.hpp b/src/buildtool/common/artifact_description.hpp
index c63a2dec..1858e41e 100644
--- a/src/buildtool/common/artifact_description.hpp
+++ b/src/buildtool/common/artifact_description.hpp
@@ -70,7 +70,7 @@ class ArtifactDescription final {
nlohmann::json const& json) noexcept
-> std::optional<ArtifactDescription>;
- [[nodiscard]] auto ToJson() const noexcept -> nlohmann::json;
+ [[nodiscard]] auto ToJson() const -> nlohmann::json;
[[nodiscard]] auto ToArtifact() const noexcept -> Artifact;