fix: decouple AI completion from history save failures and improve history API errors
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -34,6 +34,22 @@ export async function saveHistoryEntry(
|
||||
return data.entry;
|
||||
}
|
||||
|
||||
export async function saveHistoryEntrySafe(
|
||||
entry: CalcHistoryCreate,
|
||||
): Promise<
|
||||
{ ok: true; entry: CalcHistoryEntry } | { ok: false; error: string }
|
||||
> {
|
||||
try {
|
||||
const saved = await saveHistoryEntry(entry);
|
||||
return { ok: true, entry: saved };
|
||||
} catch (err) {
|
||||
return {
|
||||
ok: false,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteHistoryEntry(id: string): Promise<void> {
|
||||
const res = await fetch(`/api/history/${encodeURIComponent(id)}`, {
|
||||
method: "DELETE",
|
||||
|
||||
Reference in New Issue
Block a user