Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Add detailed error when fetching github URL failed #42

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
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
13 changes: 10 additions & 3 deletions include/antler/project/net_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ namespace antler::project {
}
}

std::string request(std::string_view org, std::string_view repo) {
std::string build_github_url(std::string_view org, std::string_view repo) {
std::string url = "https://api.github.com/repos/";
url += std::string(org) + std::string("/");
url += repo;
auto s = sender.authenticated_request(bearer_token, url.c_str());
return url;
}

std::string request(std::string_view org, std::string_view repo) {
auto s = sender.authenticated_request(bearer_token, build_github_url(org, repo).c_str());
return s;
}

Expand All @@ -122,10 +126,13 @@ namespace antler::project {
auto js = nlohmann::json::parse(request(s));
auto msg = js["message"];
if (!msg.is_null())
if (msg == "Not Found")
if (msg == "Not Found") {
system::error_log("Cannot find github repo using URL: {0}", build_github_url(get_org(s), get_repo(s)));
return false;
}
return true;
} catch(...) {
system::error_log("Unknown error when requesting URL: {0}", build_github_url(get_org(s), get_repo(s)));
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool is_github_repo(std::string_view s) { return is_github(s) && !is_archive(s);

bool is_reachable(std::string_view l) {
if (!is_github_shorthand(l)) {
system::error_log("In this version of antler-proj only github shorthands are supported. Generalized git repos and archives will be supported in a future version.");
system::error_log("In this version of antler-proj only github shorthands (i.e. org/project) are supported. Generalized git repos and archives will be supported in a future version.");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ bool project::validate_dependency(const dependency& dep) const noexcept {
if (dep.location().empty()) {
return lib_exists(dep.name());
} else if (!dep.is_valid_location()) {
system::error_log("Error denpendency: {0} is invalid.", dep.name());
system::error_log("Error dependency: {0} is invalid.", dep.name());
return false;
}
return true;
Expand Down