Browse Source

Call RequestGroup::setLastError in
PeerInteractionCommand::onFailure().

Added const Exception& argument to virtual
AbstractCommand::onFailure().

Tatsuhiro Tsujikawa 15 năm trước cách đây
mục cha
commit
a0139e3e08

+ 1 - 1
src/PeerAbstractCommand.cc

@@ -106,7 +106,7 @@ bool PeerAbstractCommand::execute()
   } catch(DownloadFailureException& err) {
     A2_LOG_ERROR_EX(EX_DOWNLOAD_ABORTED, err);
     onAbort();
-    onFailure();
+    onFailure(err);
     return true;
   } catch(RecoverableException& err) {
     A2_LOG_DEBUG_EX(fmt(MSG_TORRENT_DOWNLOAD_ABORTED,

+ 1 - 1
src/PeerAbstractCommand.h

@@ -82,7 +82,7 @@ protected:
   virtual void onAbort() {};
   // This function is called when DownloadFailureException is caught right after
   // the invocation of onAbort().
-  virtual void onFailure() {};
+  virtual void onFailure(const Exception& err) {};
   virtual bool exitBeforeExecute() = 0;
   virtual bool executeInternal() = 0;
   void setReadCheckSocket(const SharedHandle<SocketCore>& socket);

+ 2 - 1
src/PeerInteractionCommand.cc

@@ -367,8 +367,9 @@ void PeerInteractionCommand::onAbort() {
   peerStorage_->returnPeer(getPeer());
 }
 
-void PeerInteractionCommand::onFailure()
+void PeerInteractionCommand::onFailure(const Exception& err)
 {
+  requestGroup_->setLastErrorCode(err.getErrorCode());
   requestGroup_->setHaltRequested(true);
 }
 

+ 1 - 1
src/PeerInteractionCommand.h

@@ -71,7 +71,7 @@ protected:
   virtual bool executeInternal();
   virtual bool prepareForNextPeer(time_t wait);
   virtual void onAbort();
-  virtual void onFailure();
+  virtual void onFailure(const Exception& err);
   virtual bool exitBeforeExecute();
 public:
   PeerInteractionCommand(cuid_t cuid,