aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Package.cpp19
-rw-r--r--src/curl.cpp2
-rw-r--r--src/main.cpp2
3 files changed, 19 insertions, 4 deletions
diff --git a/src/Package.cpp b/src/Package.cpp
index a2c1681..6f81aab 100644
--- a/src/Package.cpp
+++ b/src/Package.cpp
@@ -13,6 +13,7 @@ using namespace rapidjson;
// Cache of package list, only stored in memory right now.
// TODO: Store this in a file as well, and update it when the remote package list updates
static Document *packageList = nullptr;
+static const char *server_url = "https://git.dec05eba.com/sibs-packages/plain/packages.json";
namespace sibs
{
@@ -116,7 +117,7 @@ namespace sibs
HttpResult httpResult = curl::get(url);
if(!httpResult.success)
- return Result<Document*>::Err(httpResult.str, httpResult.httpCode);
+ return Result<Document*>::Err(std::string("Failed to connect to ") + server_url);
Document *doc = new Document();
ParseResult parseResult = doc->Parse(httpResult.str.c_str());
@@ -136,11 +137,25 @@ namespace sibs
Result<PackageMetadata> Package::getPackage(const char *packageName, const PackageVersionRange &versionRange, Platform platform)
{
- Result<Document*> packageList = Package::getPackageList("https://git.dec05eba.com/sibs-packages/plain/packages.json");
+ #if 1
+ string errMsg = "No package with the name \"";
+ errMsg += packageName;
+ errMsg += "\" was found";
+ return Result<PackageMetadata>::Err(errMsg);
+ #endif
+
+ Result<Document*> packageList = Package::getPackageList(server_url);
if(!packageList)
return Result<PackageMetadata>::Err(packageList);
const Document &packageDoc = *packageList.unwrap();
+ if(!packageDoc.IsObject())
+ {
+ string errMsg = "Invalid response from server ";
+ errMsg += server_url;
+ errMsg += " or the server is down or your internet is down";
+ return Result<PackageMetadata>::Err(errMsg);
+ }
auto packageMetaDataJsonIt = packageDoc.FindMember(packageName);
if (packageMetaDataJsonIt == packageDoc.MemberEnd())
diff --git a/src/curl.cpp b/src/curl.cpp
index 8b4384c..55277c3 100644
--- a/src/curl.cpp
+++ b/src/curl.cpp
@@ -142,7 +142,7 @@ namespace sibs
printf("Downloading from url: %s\n", url);
CURLcode curlResponse = curl_easy_perform(curl_handle);
- long httpCode = 0;
+ long httpCode = 503;
curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl_handle);
diff --git a/src/main.cpp b/src/main.cpp
index 365cb1b..4690668 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -609,7 +609,7 @@ static int buildProject(int argc, const _tinydir_char_t **argv, bool run)
bool crossCompileLinux64ToWin64 = (SYSTEM_PLATFORM == PLATFORM_LINUX_X86_64 && platform == PLATFORM_WIN64);
if(platform != SYSTEM_PLATFORM && !crossCompileLinux64ToWin64)
{
- ferr << "Cross compilation is currently only supported from linux_X86_64 to win64" << endl;
+ ferr << "Cross compilation is currently only supported from linux_x86_64 to win64" << endl;
exit(33);
}