Skip to content

Commit f7e853c

Browse files
authored
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
1 parent 90c312f commit f7e853c

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.github/actions/spelling/allow/allow.txt

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ colorbrewer
1111
commandlines
1212
consvc
1313
copyable
14+
CText
1415
dalet
1516
dcs
1617
deselection

src/cascadia/TerminalConnection/ConptyConnection.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,20 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
428428
TerminalOutput.raise(L"\r\n");
429429
TerminalOutput.raise(badPathText);
430430
}
431+
// If the requested action requires elevation, display appropriate message
432+
else if (hr == HRESULT_FROM_WIN32(ERROR_ELEVATION_REQUIRED))
433+
{
434+
const auto elevationText = RS_(L"ElevationRequired");
435+
TerminalOutput.raise(L"\r\n");
436+
TerminalOutput.raise(elevationText);
437+
}
438+
// If the requested executable was not found, display appropriate message
439+
else if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
440+
{
441+
const auto fileNotFoundText = RS_(L"FileNotFound");
442+
TerminalOutput.raise(L"\r\n");
443+
TerminalOutput.raise(fileNotFoundText);
444+
}
431445

432446
_transitionToState(ConnectionState::Failed);
433447

src/cascadia/TerminalConnection/Resources/en-US/Resources.resw

+8-2
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
</data>
210210
<data name="CtrlDToClose" xml:space="preserve">
211211
<value>You can now close this terminal with Ctrl+D, or press Enter to restart.</value>
212-
<comment>"Ctrl+D" and "Enter" represent keys the user will press (control+D and Enter).</comment>
212+
<comment>"Ctrl+D" and "Enter" represent keys the user will press (control+D and Enter).</comment>
213213
</data>
214214
<data name="ProcessFailedToLaunch" xml:space="preserve">
215215
<value>[error {0} when launching `{1}']</value>
@@ -220,4 +220,10 @@
220220
<value>Could not access starting directory "{0}"</value>
221221
<comment>The first argument {0} is a path to a directory on the filesystem, as provided by the user.</comment>
222222
</data>
223-
</root>
223+
<data name="ElevationRequired" xml:space="preserve">
224+
<value>The requested operation requires elevation.</value>
225+
</data>
226+
<data name="FileNotFound" xml:space="preserve">
227+
<value>The system cannot find the file specified.</value>
228+
</data>
229+
</root>

0 commit comments

Comments
 (0)