mirror of https://github.com/aria2/aria2
Send the last error message as part of tellStatus RPC response
parent
9bce4eb925
commit
06b8874a49
|
@ -343,7 +343,7 @@ bool AbstractCommand::execute()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch (DlAbortEx& err) {
|
catch (DlAbortEx& err) {
|
||||||
requestGroup_->setLastErrorCode(err.getErrorCode());
|
requestGroup_->setLastErrorCode(err.getErrorCode(), err.what());
|
||||||
if (req_) {
|
if (req_) {
|
||||||
A2_LOG_ERROR_EX
|
A2_LOG_ERROR_EX
|
||||||
(fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()),
|
(fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()),
|
||||||
|
@ -376,7 +376,7 @@ bool AbstractCommand::execute()
|
||||||
A2_LOG_ERROR_EX
|
A2_LOG_ERROR_EX
|
||||||
(fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()), err);
|
(fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()), err);
|
||||||
fileEntry_->addURIResult(req_->getUri(), err.getErrorCode());
|
fileEntry_->addURIResult(req_->getUri(), err.getErrorCode());
|
||||||
requestGroup_->setLastErrorCode(err.getErrorCode());
|
requestGroup_->setLastErrorCode(err.getErrorCode(), err.what());
|
||||||
if (err.getErrorCode() == error_code::CANNOT_RESUME) {
|
if (err.getErrorCode() == error_code::CANNOT_RESUME) {
|
||||||
requestGroup_->increaseResumeFailureCount();
|
requestGroup_->increaseResumeFailureCount();
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ bool AbstractCommand::execute()
|
||||||
return prepareForRetry(0);
|
return prepareForRetry(0);
|
||||||
}
|
}
|
||||||
catch (DownloadFailureException& err) {
|
catch (DownloadFailureException& err) {
|
||||||
requestGroup_->setLastErrorCode(err.getErrorCode());
|
requestGroup_->setLastErrorCode(err.getErrorCode(), err.what());
|
||||||
if (req_) {
|
if (req_) {
|
||||||
A2_LOG_ERROR_EX
|
A2_LOG_ERROR_EX
|
||||||
(fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()),
|
(fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()),
|
||||||
|
|
|
@ -92,6 +92,8 @@ struct DownloadResult
|
||||||
|
|
||||||
error_code::Value result;
|
error_code::Value result;
|
||||||
|
|
||||||
|
std::string resultMessage;
|
||||||
|
|
||||||
bool inMemoryDownload;
|
bool inMemoryDownload;
|
||||||
|
|
||||||
DownloadResult();
|
DownloadResult();
|
||||||
|
|
|
@ -402,7 +402,7 @@ void PeerInteractionCommand::onAbort() {
|
||||||
|
|
||||||
void PeerInteractionCommand::onFailure(const Exception& err)
|
void PeerInteractionCommand::onFailure(const Exception& err)
|
||||||
{
|
{
|
||||||
requestGroup_->setLastErrorCode(err.getErrorCode());
|
requestGroup_->setLastErrorCode(err.getErrorCode(), err.what());
|
||||||
requestGroup_->setHaltRequested(true);
|
requestGroup_->setHaltRequested(true);
|
||||||
getDownloadEngine()->setRefreshInterval(std::chrono::milliseconds(0));
|
getDownloadEngine()->setRefreshInterval(std::chrono::milliseconds(0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,24 +185,24 @@ bool RequestGroup::allDownloadFinished() const
|
||||||
return pieceStorage_->allDownloadFinished();
|
return pieceStorage_->allDownloadFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code::Value RequestGroup::downloadResult() const
|
std::pair<error_code::Value, std::string> RequestGroup::downloadResult() const
|
||||||
{
|
{
|
||||||
if(downloadFinished() && !downloadContext_->isChecksumVerificationNeeded()) {
|
if(downloadFinished() && !downloadContext_->isChecksumVerificationNeeded()) {
|
||||||
return error_code::FINISHED;
|
return std::make_pair(error_code::FINISHED, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(haltReason_ == RequestGroup::USER_REQUEST) {
|
if(haltReason_ == RequestGroup::USER_REQUEST) {
|
||||||
return error_code::REMOVED;
|
return std::make_pair(error_code::REMOVED, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lastErrorCode_ == error_code::UNDEFINED) {
|
if(lastErrorCode_ == error_code::UNDEFINED) {
|
||||||
if(haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
|
if(haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
|
||||||
return error_code::IN_PROGRESS;
|
return std::make_pair(error_code::IN_PROGRESS, "");
|
||||||
}
|
}
|
||||||
return error_code::UNKNOWN_ERROR;
|
return std::make_pair(error_code::UNKNOWN_ERROR, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
return lastErrorCode_;
|
return std::make_pair(lastErrorCode_, lastErrorMessage_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestGroup::closeFile()
|
void RequestGroup::closeFile()
|
||||||
|
@ -1131,7 +1131,10 @@ std::shared_ptr<DownloadResult> RequestGroup::createDownloadResult() const
|
||||||
res->sessionDownloadLength = st.sessionDownloadLength;
|
res->sessionDownloadLength = st.sessionDownloadLength;
|
||||||
res->sessionTime = std::chrono::duration_cast<std::chrono::milliseconds>(
|
res->sessionTime = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
downloadContext_->calculateSessionTime());
|
downloadContext_->calculateSessionTime());
|
||||||
res->result = downloadResult();
|
|
||||||
|
auto result = downloadResult();
|
||||||
|
res->result = result.first;
|
||||||
|
res->resultMessage = result.second;
|
||||||
res->followedBy = followedByGIDs_;
|
res->followedBy = followedByGIDs_;
|
||||||
res->belongsTo = belongsToGID_;
|
res->belongsTo = belongsToGID_;
|
||||||
res->option = option_;
|
res->option = option_;
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "TransferStat.h"
|
#include "TransferStat.h"
|
||||||
#include "TimeA2.h"
|
#include "TimeA2.h"
|
||||||
|
@ -163,6 +164,8 @@ private:
|
||||||
|
|
||||||
error_code::Value lastErrorCode_;
|
error_code::Value lastErrorCode_;
|
||||||
|
|
||||||
|
std::string lastErrorMessage_;
|
||||||
|
|
||||||
bool saveControlFile_;
|
bool saveControlFile_;
|
||||||
|
|
||||||
bool fileAllocationEnabled_;
|
bool fileAllocationEnabled_;
|
||||||
|
@ -195,7 +198,7 @@ private:
|
||||||
// download didn't finish and error result is available in
|
// download didn't finish and error result is available in
|
||||||
// _uriResults, then last result code is returned. Otherwise
|
// _uriResults, then last result code is returned. Otherwise
|
||||||
// returns error_code::UNKNOWN_ERROR.
|
// returns error_code::UNKNOWN_ERROR.
|
||||||
error_code::Value downloadResult() const;
|
std::pair<error_code::Value, std::string> downloadResult() const;
|
||||||
|
|
||||||
void removeDefunctControlFile
|
void removeDefunctControlFile
|
||||||
(const std::shared_ptr<BtProgressInfoFile>& progressInfoFile);
|
(const std::shared_ptr<BtProgressInfoFile>& progressInfoFile);
|
||||||
|
@ -478,9 +481,10 @@ public:
|
||||||
maxUploadSpeedLimit_ = speed;
|
maxUploadSpeedLimit_ = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLastErrorCode(error_code::Value code)
|
void setLastErrorCode(error_code::Value code, const char *message = "")
|
||||||
{
|
{
|
||||||
lastErrorCode_ = code;
|
lastErrorCode_ = code;
|
||||||
|
lastErrorMessage_ = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code::Value getLastErrorCode() const
|
error_code::Value getLastErrorCode() const
|
||||||
|
|
|
@ -516,7 +516,7 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
||||||
} catch(RecoverableException& ex) {
|
} catch(RecoverableException& ex) {
|
||||||
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex);
|
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex);
|
||||||
A2_LOG_DEBUG("Deleting temporal commands.");
|
A2_LOG_DEBUG("Deleting temporal commands.");
|
||||||
groupToAdd->setLastErrorCode(ex.getErrorCode());
|
groupToAdd->setLastErrorCode(ex.getErrorCode(), ex.what());
|
||||||
// We add groupToAdd to e later in order to it is processed in
|
// We add groupToAdd to e later in order to it is processed in
|
||||||
// removeStoppedGroup().
|
// removeStoppedGroup().
|
||||||
requestQueueCheck();
|
requestQueueCheck();
|
||||||
|
|
|
@ -96,6 +96,7 @@ const char VLB_ZERO[] = "0";
|
||||||
|
|
||||||
const char KEY_GID[] = "gid";
|
const char KEY_GID[] = "gid";
|
||||||
const char KEY_ERROR_CODE[] = "errorCode";
|
const char KEY_ERROR_CODE[] = "errorCode";
|
||||||
|
const char KEY_ERROR_MESSAGE[] = "errorMessage";
|
||||||
const char KEY_STATUS[] = "status";
|
const char KEY_STATUS[] = "status";
|
||||||
const char KEY_TOTAL_LENGTH[] = "totalLength";
|
const char KEY_TOTAL_LENGTH[] = "totalLength";
|
||||||
const char KEY_COMPLETED_LENGTH[] = "completedLength";
|
const char KEY_COMPLETED_LENGTH[] = "completedLength";
|
||||||
|
@ -812,6 +813,9 @@ void gatherStoppedDownload
|
||||||
if(requested_key(keys, KEY_ERROR_CODE)) {
|
if(requested_key(keys, KEY_ERROR_CODE)) {
|
||||||
entryDict->put(KEY_ERROR_CODE, util::itos(static_cast<int>(ds->result)));
|
entryDict->put(KEY_ERROR_CODE, util::itos(static_cast<int>(ds->result)));
|
||||||
}
|
}
|
||||||
|
if(requested_key(keys, KEY_ERROR_MESSAGE)) {
|
||||||
|
entryDict->put(KEY_ERROR_MESSAGE, ds->resultMessage);
|
||||||
|
}
|
||||||
if(requested_key(keys, KEY_STATUS)) {
|
if(requested_key(keys, KEY_STATUS)) {
|
||||||
if(ds->result == error_code::REMOVED) {
|
if(ds->result == error_code::REMOVED) {
|
||||||
entryDict->put(KEY_STATUS, VLB_REMOVED);
|
entryDict->put(KEY_STATUS, VLB_REMOVED);
|
||||||
|
|
Loading…
Reference in New Issue