Staging PostgREST rejects the executiveSummary JSON-path alias, so GET /api/reports 500s. Persist a plain card_summary column from the Markdown excerpt instead. Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
839 B
TypeScript
21 lines
839 B
TypeScript
/**
|
|
* Operational log reason for unknown catch values.
|
|
*
|
|
* PostgREST / supabase-js may throw a plain object with `code` and `hint`
|
|
* instead of an Error instance. Never include message, details, or row data.
|
|
*/
|
|
export function sanitizedErrorReason(error: unknown): string {
|
|
const record = error !== null && typeof error === "object"
|
|
? error as Record<string, unknown>
|
|
: null;
|
|
const name = error instanceof Error && error.name.trim()
|
|
? error.name.trim()
|
|
: typeof record?.name === "string" && record.name.trim()
|
|
? record.name.trim()
|
|
: "UnknownError";
|
|
const code = typeof record?.code === "string" ? record.code.trim() : "";
|
|
const hint = typeof record?.hint === "string" ? record.hint.trim() : "";
|
|
if (!code && !hint) return name;
|
|
return `${name} code=${code || "none"} hint=${hint || "none"}`;
|
|
}
|