ソースを参照

Bug 1949: Improve handling of long shell command error messages

https://winscp.net/tracker/1949

Source commit: e62368857b958d84c02e837a62ab7efe4ea63e1d
Martin Prikryl 4 年 前
コミット
eaa430fbe4

+ 4 - 0
source/core/Exceptions.h

@@ -79,6 +79,10 @@ private:
       BASE(E, Ident) \
     { \
     } \
+    inline __fastcall NAME(const UnicodeString & Msg, const UnicodeString & MoreMessages, const UnicodeString & HelpKeyword = UnicodeString()) : \
+      BASE(Msg, MoreMessages, HelpKeyword) \
+    { \
+    } \
     inline __fastcall virtual ~NAME(void) \
     { \
     } \

+ 8 - 1
source/core/ScpFileSystem.cpp

@@ -650,7 +650,14 @@ void __fastcall TSCPFileSystem::ReadCommandOutput(int Params, const UnicodeStrin
         if (WrongOutput || WrongReturnCode)
         {
           DebugAssert(Cmd != NULL);
-          FTerminal->TerminalError(FMTLOAD(COMMAND_FAILED, (*Cmd, ReturnCode, Message)));
+          if (Message.IsEmpty())
+          {
+            FTerminal->TerminalError(FMTLOAD(COMMAND_FAILED_CODEONLY, (ReturnCode)));
+          }
+          else
+          {
+            throw ETerminal(MainInstructions(FMTLOAD(COMMAND_FAILED2, (*Cmd, ReturnCode))), Message);
+          }
         }
       }
     }

+ 1 - 1
source/resource/TextsCore.h

@@ -39,7 +39,7 @@
 #define USER_TERMINATED         103
 #define LOST_CONNECTION         104
 #define CANT_DETECT_RETURN_CODE 105
-#define COMMAND_FAILED          106
+#define COMMAND_FAILED2         106
 #define COMMAND_FAILED_CODEONLY 107
 #define INVALID_OUTPUT_ERROR    108
 #define READ_CURRENT_DIR_ERROR  109

+ 1 - 1
source/resource/TextsCore1.rc

@@ -8,7 +8,7 @@ BEGIN
   USER_TERMINATED, "Terminated by user."
   LOST_CONNECTION, "Lost connection."
   CANT_DETECT_RETURN_CODE, "Can't detect command return code."
-  COMMAND_FAILED, "Command '%s'\nfailed with return code %d and error message\n%s."
+  COMMAND_FAILED2, "Command '%s'\nfailed with return code %d and the following error message."
   COMMAND_FAILED_CODEONLY, "Command failed with return code %d."
   INVALID_OUTPUT_ERROR, "Command '%s' failed with invalid output '%s'."
   READ_CURRENT_DIR_ERROR, "Error getting name of current remote directory."