Add 2 additional error messages (#18462)

Add additional information to 2 error scenarios when launching a
different profile in the `ConptyConnection.cpp` file.
  - Requires Elevation
  - File Not Found

Created a profile that required elevation and verified the error
message. Created profile that passed a made up command and verified the
error message.

Closes #7186

(cherry picked from commit f7e853cd9f515ff0c7e52ab0eb0604bb95d47ba3)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgZlxJY
Service-Version: 1.23
This commit is contained in:
Dustin Hall 2025-04-14 17:15:11 -06:00 committed by Dustin L. Howett
parent b2cf9d1bac
commit ca218d3d7a
3 changed files with 23 additions and 2 deletions

View File

@ -11,6 +11,7 @@ colorbrewer
commandlines commandlines
consvc consvc
copyable copyable
CText
dalet dalet
dcs dcs
deselection deselection

View File

@ -428,6 +428,20 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
TerminalOutput.raise(L"\r\n"); TerminalOutput.raise(L"\r\n");
TerminalOutput.raise(badPathText); TerminalOutput.raise(badPathText);
} }
// If the requested action requires elevation, display appropriate message
else if (hr == HRESULT_FROM_WIN32(ERROR_ELEVATION_REQUIRED))
{
const auto elevationText = RS_(L"ElevationRequired");
TerminalOutput.raise(L"\r\n");
TerminalOutput.raise(elevationText);
}
// If the requested executable was not found, display appropriate message
else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
{
const auto fileNotFoundText = RS_(L"FileNotFound");
TerminalOutput.raise(L"\r\n");
TerminalOutput.raise(fileNotFoundText);
}
_transitionToState(ConnectionState::Failed); _transitionToState(ConnectionState::Failed);

View File

@ -209,7 +209,7 @@
</data> </data>
<data name="CtrlDToClose" xml:space="preserve"> <data name="CtrlDToClose" xml:space="preserve">
<value>You can now close this terminal with Ctrl+D, or press Enter to restart.</value> <value>You can now close this terminal with Ctrl+D, or press Enter to restart.</value>
<comment>"Ctrl+D" and "Enter" represent keys the user will press (control+D and Enter).</comment> <comment>"Ctrl+D" and "Enter" represent keys the user will press (control+D and Enter).</comment>
</data> </data>
<data name="ProcessFailedToLaunch" xml:space="preserve"> <data name="ProcessFailedToLaunch" xml:space="preserve">
<value>[error {0} when launching `{1}']</value> <value>[error {0} when launching `{1}']</value>
@ -220,4 +220,10 @@
<value>Could not access starting directory "{0}"</value> <value>Could not access starting directory "{0}"</value>
<comment>The first argument {0} is a path to a directory on the filesystem, as provided by the user.</comment> <comment>The first argument {0} is a path to a directory on the filesystem, as provided by the user.</comment>
</data> </data>
<data name="ElevationRequired" xml:space="preserve">
<value>The requested operation requires elevation.</value>
</data>
<data name="FileNotFound" xml:space="preserve">
<value>The system cannot find the file specified.</value>
</data>
</root> </root>