[fix] simple theme: show why the AI summary failed
The error box said only "Error loading the AI summary". The status of the failed request was raised and then dropped, so a user could not tell an LLM server that is unreachable (502) from a plugin that is switched off (403) or a request that was rejected (400). The reason is now appended to the message. On a phone or in a webview, where dev tools are not an option, it is the only thing the person looking at the failure has to go on. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0cc3748866
commit
054b3a5c0d
@@ -157,7 +157,9 @@ export default class AiSummary extends Plugin {
|
||||
signal: controller.signal
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error(res.statusText);
|
||||
// the status is shown to the user: it is often the only thing
|
||||
// available to diagnose a failure on a device without dev tools
|
||||
throw new Error(`HTTP ${res.status}`);
|
||||
}
|
||||
|
||||
if (res.body) {
|
||||
@@ -195,8 +197,11 @@ export default class AiSummary extends Plugin {
|
||||
private static showError(box: HTMLElement, error: unknown): void {
|
||||
console.error("Error loading AI summary:", error);
|
||||
|
||||
const message = settings.translations?.error_loading_ai_summary ?? "Error loading the AI summary";
|
||||
const reason = error instanceof Error && error.message ? ` (${error.message})` : "";
|
||||
|
||||
const errorElement = Object.assign(document.createElement("div"), {
|
||||
textContent: settings.translations?.error_loading_ai_summary ?? "Error loading the AI summary",
|
||||
textContent: `${message}${reason}`,
|
||||
className: "dialog-error"
|
||||
});
|
||||
errorElement.setAttribute("role", "alert");
|
||||
|
||||
Reference in New Issue
Block a user