Skip to content

Commit

Permalink
feat: better error message with bad data
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Aug 9, 2024
1 parent 6715fd6 commit d4a0ffa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bzlreg/add_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ auto bzlreg::add_module(add_module_options options) -> int {

auto archive_url = boost::urls::url{archive_url_str};
auto archive_filename = fs::path{archive_url.path()}.filename().string();
if(!archive_filename.ends_with(".tar.gz") && !archive_filename.ends_with(".tgz")) {
if(!archive_filename.ends_with(".tar.gz") &&
!archive_filename.ends_with(".tgz")) {
std::cerr << std::format(
"Archive {} is not supported. Only .tar.gz archives are allowed.\n",
archive_filename
Expand All @@ -123,6 +124,10 @@ auto bzlreg::add_module(add_module_options options) -> int {
}

auto decompressed_data = bzlreg::decompress_archive(*compressed_data);
if(decompressed_data.empty()) {
std::cerr << "Failed to decompress archive data\n";
return 1;
}

auto tar_view = bzlreg::tar_view{decompressed_data};

Expand Down

0 comments on commit d4a0ffa

Please sign in to comment.