Skip to content

Commit 556a641

Browse files
committed
Add 3 additional error messages
Add additional information to 3 error senarios when launching a different profile in the ConptyConnection. - Requires Elevation - CTRL+C - Bad Command or File Not Found closes microsoft#7186
1 parent 08f9afe commit 556a641

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/cascadia/TerminalConnection/ConptyConnection.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,28 @@ 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 a stop signal (ctrl+c) is detected, display appropriate message
439+
else if (hr == HRESULT_FROM_NT(STATUS_CONTROL_C_EXIT))
440+
{
441+
const auto ctrlCText = RS_(L"CtrlCToClose");
442+
TerminalOutput.raise(L"\r\n");
443+
TerminalOutput.raise(ctrlCText);
444+
}
445+
// If the command or file is invalid, display appropriate message
446+
else if (hr == HRESULT_FROM_WIN32(ERROR_BAD_COMMAND) || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
447+
{
448+
const auto badCommandText = RS_fmt(L"BadCommandOrFile", _commandline);
449+
TerminalOutput.raise(L"\r\n");
450+
TerminalOutput.raise(badCommandText);
451+
}
452+
431453

432454
_transitionToState(ConnectionState::Failed);
433455

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

Lines changed: 12 additions & 2 deletions
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,14 @@
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="CtrlCToClose" xml:space="preserve">
227+
<value>{Application Exit by CTRL+C} The application terminated as a result of a CTRL+C.</value>
228+
</data>
229+
<data name="BadCommandOrFile" xml:space="preserve">
230+
<value>{0} is not recognized as an internal or external command, operable program or batch file.</value>
231+
<comment>The first argument {0} is the command or file, as provided by the user</comment>
232+
</data>
233+
</root>

0 commit comments

Comments
 (0)