Skip to content

Commit

Permalink
Add 3 additional error messages
Browse files Browse the repository at this point in the history
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
  • Loading branch information
halldk committed Jan 26, 2025
1 parent 08f9afe commit 556a641
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/cascadia/TerminalConnection/ConptyConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,28 @@ 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 a stop signal (ctrl+c) is detected, display appropriate message
else if (hr == HRESULT_FROM_NT(STATUS_CONTROL_C_EXIT))
{
const auto ctrlCText = RS_(L"CtrlCToClose");
TerminalOutput.raise(L"\r\n");
TerminalOutput.raise(ctrlCText);
}
// If the command or file is invalid, display appropriate message
else if (hr == HRESULT_FROM_WIN32(ERROR_BAD_COMMAND) || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
{
const auto badCommandText = RS_fmt(L"BadCommandOrFile", _commandline);
TerminalOutput.raise(L"\r\n");
TerminalOutput.raise(badCommandText);
}


_transitionToState(ConnectionState::Failed);

Expand Down
14 changes: 12 additions & 2 deletions src/cascadia/TerminalConnection/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
</data>
<data name="CtrlDToClose" xml:space="preserve">
<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 name="ProcessFailedToLaunch" xml:space="preserve">
<value>[error {0} when launching `{1}']</value>
Expand All @@ -220,4 +220,14 @@
<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>
</data>
</root>
<data name="ElevationRequired" xml:space="preserve">
<value>The requested operation requires elevation.</value>
</data>
<data name="CtrlCToClose" xml:space="preserve">
<value>{Application Exit by CTRL+C} The application terminated as a result of a CTRL+C.</value>
</data>
<data name="BadCommandOrFile" xml:space="preserve">
<value>{0} is not recognized as an internal or external command, operable program or batch file.</value>
<comment>The first argument {0} is the command or file, as provided by the user</comment>
</data>
</root>

0 comments on commit 556a641

Please sign in to comment.