mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Fix: Prevent CLI from crashing when a configured theme is not found
Previously, if a theme specified in the user's settings was not found, the CLI would crash during startup. This was particularly affecting users upgrading from older versions as the "ANSI colors only" theme was renamed to "ANSI". This commit adds error handling to catch the theme not found error during initial loading and when setting themes later. Instead of crashing, the application now logs a warning, displays an error message in the UI, and opens the theme selection dialog to allow the user to choose a valid theme.
This commit is contained in:
committed by
N. Taylor Mullen
parent
4741c9a6eb
commit
1c486a4050
@@ -24,7 +24,24 @@ async function main() {
|
||||
const settings = loadSettings(process.cwd());
|
||||
const config = await loadCliConfig(settings.merged);
|
||||
if (settings.merged.theme) {
|
||||
themeManager.setActiveTheme(settings.merged.theme);
|
||||
try {
|
||||
themeManager.setActiveTheme(settings.merged.theme);
|
||||
} catch (error: unknown) {
|
||||
// If the theme is not found during initial load, log a warning and continue.
|
||||
// The useThemeCommand hook in App.tsx will handle opening the dialog.
|
||||
if (
|
||||
error instanceof Error &&
|
||||
error.message.includes('Theme') &&
|
||||
error.message.includes('not found')
|
||||
) {
|
||||
console.warn(
|
||||
`Warning: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
} else {
|
||||
// Re-throw other errors to be caught by the main catch block
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hop into sandbox if we are outside and sandboxing is enabled
|
||||
|
||||
Reference in New Issue
Block a user