summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/themes
diff options
context:
space:
mode:
authorTaylor Mullen <[email protected]>2025-05-09 10:20:08 -0700
committerN. Taylor Mullen <[email protected]>2025-05-09 10:28:20 -0700
commitb8fa38a6e8f60acf6489fde545a91d3ba4c395d7 (patch)
tree9f5950e4bf5c644a9890786a43243e2859ad3642 /packages/cli/src/ui/themes
parentc58f8790265fc80b52dbba1127f2c2e5b90ef737 (diff)
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.
Diffstat (limited to 'packages/cli/src/ui/themes')
-rw-r--r--packages/cli/src/ui/themes/theme-manager.ts13
1 files changed, 11 insertions, 2 deletions
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;
}
}