[PR #12432] [MERGED] Allow exceptions from ITerminalApi and TerminalDispatch #29034

Open
opened 2026-01-31 09:32:22 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/12432
Author: @j4james
Created: 2/8/2022
Status: Merged
Merged: 2/9/2022
Merged by: @DHowett

Base: mainHead: exceptions-in-terminal


📝 Commits (3)

  • b3f36af Allow exceptions thrown from TerminalDispatch.
  • 6d6eaf5 Allow exceptions thrown from ITerminalApi.
  • e4e0469 Remove unneeded bool returns from ITerminalApi.

📊 Changes

8 files changed (+437 additions, -525 deletions)

View changed files

📝 src/cascadia/TerminalCore/ITerminalApi.hpp (+32 -32)
📝 src/cascadia/TerminalCore/Terminal.hpp (+41 -41)
📝 src/cascadia/TerminalCore/TerminalApi.cpp (+49 -125)
📝 src/cascadia/TerminalCore/TerminalDispatch.cpp (+149 -167)
📝 src/cascadia/TerminalCore/TerminalDispatch.hpp (+54 -54)
📝 src/cascadia/TerminalCore/TerminalDispatchGraphics.cpp (+8 -6)
📝 src/cascadia/UnitTests_TerminalCore/TerminalApiTest.cpp (+4 -4)
📝 src/terminal/adapter/termDispatch.hpp (+100 -96)

📄 Description

This PR updates the ITerminalApi and TerminalDispatch classes to
allow exceptions to be thrown in case of errors instead of using boolean
return values.

References

This brings the Terminal code into alignment with the AdaptDispatch
and ConGetSet changes made in PR #12247.

And while this isn't exactly a fix for #12378, it does at least stop the
app from crashing now.

PR Checklist

  • CLA signed.
  • Tests added/passed
  • Documentation updated.
  • Schema updated.
  • I've discussed this with core contributors already. Issue number
    where discussion took place: #12378

Detailed Description of the Pull Request / Additional comments

All the TerminalDispatch methods have had their noexcept specifiers
dropped, and any try/catch wrapping removed, so exceptions will now
fall through to the StateMachine class where they should be safely
caught and logged.

The same goes for the ITerminalApi interface and its implementation in
the Terminal class. And many of the methods in this interface have
also had their bool return values changed to void, since there is
usually not a need for error return values now.

Validation Steps Performed

I've manually tested the OSC 9;9 sequence described in #12378 and
confirmed that it no longer crashes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/12432 **Author:** [@j4james](https://github.com/j4james) **Created:** 2/8/2022 **Status:** ✅ Merged **Merged:** 2/9/2022 **Merged by:** [@DHowett](https://github.com/DHowett) **Base:** `main` ← **Head:** `exceptions-in-terminal` --- ### 📝 Commits (3) - [`b3f36af`](https://github.com/microsoft/terminal/commit/b3f36af2685c0ee87e639872c2241585915317f6) Allow exceptions thrown from TerminalDispatch. - [`6d6eaf5`](https://github.com/microsoft/terminal/commit/6d6eaf54f53a6bf77156f4d4a45647ff65341925) Allow exceptions thrown from ITerminalApi. - [`e4e0469`](https://github.com/microsoft/terminal/commit/e4e0469b13893b67401e8260dc9467098a47966a) Remove unneeded bool returns from ITerminalApi. ### 📊 Changes **8 files changed** (+437 additions, -525 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalCore/ITerminalApi.hpp` (+32 -32) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+41 -41) 📝 `src/cascadia/TerminalCore/TerminalApi.cpp` (+49 -125) 📝 `src/cascadia/TerminalCore/TerminalDispatch.cpp` (+149 -167) 📝 `src/cascadia/TerminalCore/TerminalDispatch.hpp` (+54 -54) 📝 `src/cascadia/TerminalCore/TerminalDispatchGraphics.cpp` (+8 -6) 📝 `src/cascadia/UnitTests_TerminalCore/TerminalApiTest.cpp` (+4 -4) 📝 `src/terminal/adapter/termDispatch.hpp` (+100 -96) </details> ### 📄 Description This PR updates the `ITerminalApi` and `TerminalDispatch` classes to allow exceptions to be thrown in case of errors instead of using boolean return values. ## References This brings the Terminal code into alignment with the `AdaptDispatch` and `ConGetSet` changes made in PR #12247. And while this isn't exactly a fix for #12378, it does at least stop the app from crashing now. ## PR Checklist * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [x] I've discussed this with core contributors already. Issue number where discussion took place: #12378 ## Detailed Description of the Pull Request / Additional comments All the `TerminalDispatch` methods have had their `noexcept` specifiers dropped, and any `try`/`catch` wrapping removed, so exceptions will now fall through to the `StateMachine` class where they should be safely caught and logged. The same goes for the `ITerminalApi` interface and its implementation in the `Terminal` class. And many of the methods in this interface have also had their `bool` return values changed to `void`, since there is usually not a need for error return values now. ## Validation Steps Performed I've manually tested the `OSC 9;9` sequence described in #12378 and confirmed that it no longer crashes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:32:22 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29034