Browse Source

Improving formatting of some messages

Source commit: 24e69c72eefcea67a2c2ae0d6252d697d9e8d422
Martin Prikryl 6 years ago
parent
commit
fcce1b39c8

+ 2 - 2
source/core/SessionInfo.cpp

@@ -925,7 +925,7 @@ void __fastcall TSessionLog::Add(TLogLineType Type, const UnicodeString & Line)
       FConfiguration->Logging = false;
       try
       {
-        throw ExtException(&E, LoadStr(LOG_GEN_ERROR));
+        throw ExtException(&E, MainInstructions(LoadStr(LOG_GEN_ERROR)));
       }
       catch (Exception &E)
       {
@@ -1008,7 +1008,7 @@ void __fastcall TSessionLog::OpenLogFile()
     FConfiguration->LogFileName = UnicodeString();
     try
     {
-      throw ExtException(&E, LoadStr(LOG_GEN_ERROR));
+      throw ExtException(&E, MainInstructions(LoadStr(LOG_GEN_ERROR)));
     }
     catch (Exception & E)
     {

+ 1 - 1
source/core/Terminal.cpp

@@ -2748,7 +2748,7 @@ void __fastcall TTerminal::CloseOnCompletion(
     LogEvent(L"Closing session after completed operation (as requested by user)");
     Close();
     throw ESshTerminate(NULL,
-      Message.IsEmpty() ? UnicodeString(LoadStr(CLOSED_ON_COMPLETION)) : Message,
+      MainInstructions(Message.IsEmpty() ? LoadStr(CLOSED_ON_COMPLETION) : Message),
       Operation, TargetLocalPath, DestLocalFileName);
   }
 }

+ 5 - 2
source/windows/UserInterface.cpp

@@ -267,9 +267,12 @@ void __fastcall ShowExtendedExceptionEx(TTerminal * Terminal,
         if (ForActiveTerminal)
         {
           UnicodeString MessageFormat =
-            MainInstructions((Manager->Count > 1) ?
+            (Manager->Count > 1) ?
               FMTLOAD(DISCONNECT_ON_COMPLETION, (Manager->Count - 1)) :
-              LoadStr(EXIT_ON_COMPLETION));
+              LoadStr(EXIT_ON_COMPLETION);
+          // Remove the leading "%s\n\n" (not to change the translation originals - previously the error message was prepended)
+          MessageFormat = FORMAT(MessageFormat, (UnicodeString())).Trim();
+          MessageFormat = MainInstructions(MessageFormat) + L"\n\n%s";
           Result = FatalExceptionMessageDialog(E, qtInformation, 0,
             MessageFormat,
             Answers | qaYes | qaNo, HELP_NONE, &Params);

+ 5 - 2
source/windows/WinInterface.cpp

@@ -657,6 +657,10 @@ unsigned int __fastcall ExceptionMessageDialog(Exception * E, TQueryType Type,
   // this is always called from within ExceptionMessage check,
   // so it should never fail here
   DebugCheck(ExceptionMessageFormatted(E, Message));
+  if (!MessageFormat.IsEmpty())
+  {
+    Message = FORMAT(MessageFormat, (UnformatMessage(Message)));
+  }
 
   HelpKeyword = MergeHelpKeyword(HelpKeyword, GetExceptionHelpKeyword(E));
 
@@ -667,8 +671,7 @@ unsigned int __fastcall ExceptionMessageDialog(Exception * E, TQueryType Type,
   }
 
   return MoreMessageDialog(
-    FORMAT(MessageFormat.IsEmpty() ? UnicodeString(L"%s") : MessageFormat, (Message)),
-    MoreMessages, Type, Answers, HelpKeyword, Params);
+    Message, MoreMessages, Type, Answers, HelpKeyword, Params);
 }
 //---------------------------------------------------------------------------
 unsigned int __fastcall FatalExceptionMessageDialog(Exception * E, TQueryType Type,