misc: improve timeout handling and warnings in skills (#211)
This commit is contained in:
@@ -142,7 +142,13 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
|
||||
set({ skills: combinedSkills, loading: false });
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch skills:', error);
|
||||
set({ loading: false });
|
||||
let errorMsg = error instanceof Error ? error.message : String(error);
|
||||
if (errorMsg.includes('Timeout')) {
|
||||
errorMsg = 'timeoutError';
|
||||
} else if (errorMsg.toLowerCase().includes('rate limit')) {
|
||||
errorMsg = 'rateLimitError';
|
||||
}
|
||||
set({ loading: false, error: errorMsg });
|
||||
}
|
||||
},
|
||||
|
||||
@@ -153,6 +159,12 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
|
||||
if (result.success) {
|
||||
set({ searchResults: result.results || [] });
|
||||
} else {
|
||||
if (result.error?.includes('Timeout')) {
|
||||
throw new Error('searchTimeoutError');
|
||||
}
|
||||
if (result.error?.toLowerCase().includes('rate limit')) {
|
||||
throw new Error('searchRateLimitError');
|
||||
}
|
||||
throw new Error(result.error || 'Search failed');
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -167,6 +179,12 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
|
||||
try {
|
||||
const result = await window.electron.ipcRenderer.invoke('clawhub:install', { slug, version }) as { success: boolean; error?: string };
|
||||
if (!result.success) {
|
||||
if (result.error?.includes('Timeout')) {
|
||||
throw new Error('installTimeoutError');
|
||||
}
|
||||
if (result.error?.toLowerCase().includes('rate limit')) {
|
||||
throw new Error('installRateLimitError');
|
||||
}
|
||||
throw new Error(result.error || 'Install failed');
|
||||
}
|
||||
// Refresh skills after install
|
||||
|
||||
Reference in New Issue
Block a user