Improve logging on error

This commit is contained in:
Maschell 2023-01-18 21:33:19 +01:00
parent ad337f97fe
commit afcaeb32f6
3 changed files with 10 additions and 5 deletions

View File

@ -31,7 +31,7 @@ int DownloadFilesThreadEntry(UpdaterState *updater) {
int errorCode;
std::string errorText;
if (DownloadUtils::DownloadFileToBuffer(curURL, downloadedZIP, responseCode, errorCode, errorText, &updater->mProgress) < 0 || responseCode != 200) {
DEBUG_FUNCTION_LINE_ERR("Download failed");
DEBUG_FUNCTION_LINE_ERR("Download failed for %s. curl error code %d, error text %s, response code: %d", curURL.c_str(), errorCode, errorText.c_str(), responseCode);
{
std::lock_guard<std::mutex> lockInfo(updater->mDownloadInfosLock);
updater->mDownloadInfos->state = DownloadInfos::DOWNLOAD_FAILED;
@ -89,7 +89,7 @@ int DownloadFilesThreadEntry(UpdaterState *updater) {
}
if (!found) {
DEBUG_FUNCTION_LINE_ERR("Failed to find file in zip");
DEBUG_FUNCTION_LINE_ERR("Failed to find with hash %s in zip (%s)", curFile.getSha1().c_str(), curURL.c_str());
{
std::lock_guard<std::mutex> lockInfo(updater->mDownloadInfosLock);
updater->mDownloadInfos->state = DownloadInfos::DOWNLOAD_NOT_FOUND_IN_ZIP;

View File

@ -10,14 +10,19 @@
int DownloadVersionInfoThreadEntry(UpdaterState *updater) {
std::lock_guard<std::mutex> lock(updater->mVersionBufferLock);
updater->mProgress = 0.0f;
if (DownloadUtils::DownloadFileToBuffer(UPDATE_SERVER_URL "/api/check_versions",
std::string url = UPDATE_SERVER_URL "/api/check_versions";
if (DownloadUtils::DownloadFileToBuffer(url,
updater->mVersionBuffer,
updater->mResponseCode,
updater->mDownloadErrorCode,
updater->mDownloadErrorText,
&updater->mProgress) < 0 ||
updater->mResponseCode != 200) {
DEBUG_FUNCTION_LINE_ERR("Error while downloading");
DEBUG_FUNCTION_LINE_ERR("Error while downloading \"%s\".", url.c_str());
DEBUG_FUNCTION_LINE_ERR("curl error code: %d, curl error text %s, response code: %d",
updater->mDownloadErrorCode,
updater->mDownloadErrorText.c_str(),
updater->mResponseCode);
updater->mDownloadInfoResult = UpdaterState::DOWNLOAD_FAILED;
} else {
updater->mDownloadInfoResult = UpdaterState::DOWNLOAD_SUCCESS;

View File

@ -139,7 +139,7 @@ int32_t CreateSubfolder(const char *fullpath) {
int32_t saveBufferToFile(const char *path, void *buffer, uint32_t size) {
int fd = open(path, O_CREAT | O_TRUNC | O_WRONLY);
if (fd < 0) {
DEBUG_FUNCTION_LINE_ERR("Failed to open %s", path);
DEBUG_FUNCTION_LINE_ERR("Failed to open %s. %d", path, fd);
return -1;
}
auto sizeToWrite = size;