Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libs/linglong/src/linglong/package/layer_packager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ LayerPackager::pack(const LayerDir &dir, const QString &layerFilePath) const
}

auto result = LayerFile::New(layerFilePath);
Q_ASSERT(result.has_value());
if (!result) {
return LINGLONG_ERR(result);
}

return result;
Comment on lines 168 to 173

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the current error handling is correct, it can be made more concise by using map_error from tl::expected. This avoids the explicit if block and intermediate variable, making the intent of wrapping the error and returning clearer.

    return LayerFile::New(layerFilePath).map_error([&](auto &&err) {
        return LINGLONG_ERRV(std::move(err));
    });

}
Expand Down
Loading