Simplify handlers & IPC client: move from Result pattern to throwing errors (#120)

This commit is contained in:
Will Chen
2025-05-09 15:14:12 -07:00
committed by GitHub
parent 26305ee090
commit c71638a508
25 changed files with 618 additions and 990 deletions

View File

@@ -47,20 +47,17 @@ export async function fetchOllamaModels(): Promise<LocalModelListResponse> {
};
});
logger.info(`Successfully fetched ${models.length} models from Ollama`);
return { models, error: null };
return { models };
} catch (error) {
if (
error instanceof TypeError &&
(error as Error).message.includes("fetch failed")
) {
logger.error("Could not connect to Ollama");
return {
models: [],
error:
"Could not connect to Ollama. Make sure it's running at http://localhost:11434",
};
throw new Error(
"Could not connect to Ollama. Make sure it's running at http://localhost:11434",
);
}
return { models: [], error: "Failed to fetch models from Ollama" };
throw new Error("Failed to fetch models from Ollama");
}
}