Fix saveField to properly reject on failure

Previously when the content API returned a non-ok response,
saveField would set error state but still resolve the promise.
This caused downstream code to think save succeeded when it failed.

Now properly extracts error message from response and throws.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
Kunthawat GreethongandClaude Opus 4.6 committed 2026-05-04 09:35:57 +07:00
1 parent 2d1be52177
commit 2d77509f76
1 file changed
+5
@@ -721,6 +721,11 @@ export function renderToolbar(config: ToolbarConfig): string {
} else {
setSaveState("error");
console.error("Save failed:", res.status);
// Reject the promise so callers know save failed
return res.json().then(function(e) {
var msg = (e && e.error && e.error.message) ? e.error.message : ("Save failed: " + res.status);
throw new Error(msg);
});
}
})
.catch(function(err) {