diff --git a/packages/common/src/types/TalonSpokenForms.ts b/packages/common/src/types/TalonSpokenForms.ts index b561f61574..63744b934f 100644 --- a/packages/common/src/types/TalonSpokenForms.ts +++ b/packages/common/src/types/TalonSpokenForms.ts @@ -42,3 +42,10 @@ export class NeedsInitialTalonUpdateError extends Error { this.name = "NeedsInitialTalonUpdateError"; } } + +export class DisabledCustomSpokenFormsError extends Error { + constructor() { + super("Custom spoken forms are not currently supported in this ide"); + this.name = "DisabledCustomSpokenFormsError"; + } +} diff --git a/packages/cursorless-engine/src/disabledComponents/DisabledTalonSpokenForms.ts b/packages/cursorless-engine/src/disabledComponents/DisabledTalonSpokenForms.ts index bb47a9347f..c188a8ddf0 100644 --- a/packages/cursorless-engine/src/disabledComponents/DisabledTalonSpokenForms.ts +++ b/packages/cursorless-engine/src/disabledComponents/DisabledTalonSpokenForms.ts @@ -1,8 +1,12 @@ -import type { SpokenFormEntry, TalonSpokenForms } from "@cursorless/common"; +import { + DisabledCustomSpokenFormsError, + type SpokenFormEntry, + type TalonSpokenForms, +} from "@cursorless/common"; export class DisabledTalonSpokenForms implements TalonSpokenForms { getSpokenFormEntries(): Promise { - throw Error("Talon spoken forms are not implemented."); + throw new DisabledCustomSpokenFormsError(); } onDidChange() { diff --git a/packages/cursorless-engine/src/spokenForms/CustomSpokenForms.ts b/packages/cursorless-engine/src/spokenForms/CustomSpokenForms.ts index 84a3197c04..0c3257f3dd 100644 --- a/packages/cursorless-engine/src/spokenForms/CustomSpokenForms.ts +++ b/packages/cursorless-engine/src/spokenForms/CustomSpokenForms.ts @@ -1,5 +1,6 @@ import { CustomRegexScopeType, + DisabledCustomSpokenFormsError, Disposable, NeedsInitialTalonUpdateError, Notifier, @@ -81,6 +82,8 @@ export class CustomSpokenForms { if (err instanceof NeedsInitialTalonUpdateError) { // Handle case where spokenForms.json doesn't exist yet this.needsInitialTalonUpdate_ = true; + } else if (err instanceof DisabledCustomSpokenFormsError) { + // Do nothing: this ide doesn't currently support custom spoken forms } else { console.error("Error loading custom spoken forms", err); const msg = (err as Error).message.replace(/\.$/, "");