Skip to content

Commit ef04390

Browse files
Added disabled spoken forms error (#2509)
## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: Pokey Rule <[email protected]>
1 parent b9590b4 commit ef04390

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

packages/common/src/types/TalonSpokenForms.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,10 @@ export class NeedsInitialTalonUpdateError extends Error {
4242
this.name = "NeedsInitialTalonUpdateError";
4343
}
4444
}
45+
46+
export class DisabledCustomSpokenFormsError extends Error {
47+
constructor() {
48+
super("Custom spoken forms are not currently supported in this ide");
49+
this.name = "DisabledCustomSpokenFormsError";
50+
}
51+
}

packages/cursorless-engine/src/disabledComponents/DisabledTalonSpokenForms.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import type { SpokenFormEntry, TalonSpokenForms } from "@cursorless/common";
1+
import {
2+
DisabledCustomSpokenFormsError,
3+
type SpokenFormEntry,
4+
type TalonSpokenForms,
5+
} from "@cursorless/common";
26

37
export class DisabledTalonSpokenForms implements TalonSpokenForms {
48
getSpokenFormEntries(): Promise<SpokenFormEntry[]> {
5-
throw Error("Talon spoken forms are not implemented.");
9+
throw new DisabledCustomSpokenFormsError();
610
}
711

812
onDidChange() {

packages/cursorless-engine/src/spokenForms/CustomSpokenForms.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
CustomRegexScopeType,
3+
DisabledCustomSpokenFormsError,
34
Disposable,
45
NeedsInitialTalonUpdateError,
56
Notifier,
@@ -81,6 +82,8 @@ export class CustomSpokenForms {
8182
if (err instanceof NeedsInitialTalonUpdateError) {
8283
// Handle case where spokenForms.json doesn't exist yet
8384
this.needsInitialTalonUpdate_ = true;
85+
} else if (err instanceof DisabledCustomSpokenFormsError) {
86+
// Do nothing: this ide doesn't currently support custom spoken forms
8487
} else {
8588
console.error("Error loading custom spoken forms", err);
8689
const msg = (err as Error).message.replace(/\.$/, "");

0 commit comments

Comments
 (0)