From ca218d3d7a7ba08c01e153a4134db7d085e58b09 Mon Sep 17 00:00:00 2001 From: Dustin Hall <1168515+halldk@users.noreply.github.com> Date: Mon, 14 Apr 2025 17:15:11 -0600 Subject: [PATCH] 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 --- .github/actions/spelling/allow/allow.txt | 1 + .../TerminalConnection/ConptyConnection.cpp | 14 ++++++++++++++ .../Resources/en-US/Resources.resw | 10 ++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/actions/spelling/allow/allow.txt b/.github/actions/spelling/allow/allow.txt index 630edfebce..a936b3df35 100644 --- a/.github/actions/spelling/allow/allow.txt +++ b/.github/actions/spelling/allow/allow.txt @@ -11,6 +11,7 @@ colorbrewer commandlines consvc copyable +CText dalet dcs deselection diff --git a/src/cascadia/TerminalConnection/ConptyConnection.cpp b/src/cascadia/TerminalConnection/ConptyConnection.cpp index 95517373c7..613ad50c91 100644 --- a/src/cascadia/TerminalConnection/ConptyConnection.cpp +++ b/src/cascadia/TerminalConnection/ConptyConnection.cpp @@ -428,6 +428,20 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation TerminalOutput.raise(L"\r\n"); 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); diff --git a/src/cascadia/TerminalConnection/Resources/en-US/Resources.resw b/src/cascadia/TerminalConnection/Resources/en-US/Resources.resw index 3532e31049..82c7291a60 100644 --- a/src/cascadia/TerminalConnection/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalConnection/Resources/en-US/Resources.resw @@ -209,7 +209,7 @@ You can now close this terminal with Ctrl+D, or press Enter to restart. - "Ctrl+D" and "Enter" represent keys the user will press (control+D and Enter). + "Ctrl+D" and "Enter" represent keys the user will press (control+D and Enter). [error {0} when launching `{1}'] @@ -220,4 +220,10 @@ Could not access starting directory "{0}" The first argument {0} is a path to a directory on the filesystem, as provided by the user. - + + The requested operation requires elevation. + + + The system cannot find the file specified. + + \ No newline at end of file