From b8fa38a6e8f60acf6489fde545a91d3ba4c395d7 Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Fri, 9 May 2025 10:20:08 -0700 Subject: feat: Improve theme not found handling Modify to return a boolean instead of throwing an error when a theme is not found. Update CLI startup and hook to handle the boolean return value for more graceful error handling. --- packages/cli/src/ui/themes/theme-manager.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'packages/cli/src/ui/themes/theme-manager.ts') diff --git a/packages/cli/src/ui/themes/theme-manager.ts b/packages/cli/src/ui/themes/theme-manager.ts index d1f8df9c..e17fa5b7 100644 --- a/packages/cli/src/ui/themes/theme-manager.ts +++ b/packages/cli/src/ui/themes/theme-manager.ts @@ -73,14 +73,23 @@ class ThemeManager { /** * Sets the active theme. * @param themeName The name of the theme to activate. + * @returns True if the theme was successfully set, false otherwise. */ - setActiveTheme(themeName: string | undefined): void { + setActiveTheme(themeName: string | undefined): boolean { const foundTheme = this.findThemeByName(themeName); if (foundTheme) { this.activeTheme = foundTheme; + return true; } else { - throw new Error(`Theme "${themeName}" not found.`); + // If themeName is undefined, it means we want to set the default theme. + // If findThemeByName returns undefined (e.g. default theme is also not found for some reason) + // then this will return false. + if (themeName === undefined) { + this.activeTheme = DEFAULT_THEME; + return true; + } + return false; } } -- cgit v1.2.3