|
@@ -1519,7 +1519,16 @@ Return ONLY the JSON array, no markdown or explanation.`,
|
|
|
}))
|
|
}))
|
|
|
.mutation(async ({ input }) => {
|
|
.mutation(async ({ input }) => {
|
|
|
if (input.replaceAll) await deleteAllKnowledgeProducts();
|
|
if (input.replaceAll) await deleteAllKnowledgeProducts();
|
|
|
- return bulkCreateKnowledgeProducts(input.products);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ return await bulkCreateKnowledgeProducts(input.products);
|
|
|
|
|
+ } catch (err: any) {
|
|
|
|
|
+ const cause = err?.cause?.message || err?.cause?.toString() || "";
|
|
|
|
|
+ const msg = err?.message || String(err);
|
|
|
|
|
+ // Extract the real PG error (after the SQL dump)
|
|
|
|
|
+ const pgErr = cause || msg.split("\n").filter(Boolean).pop() || msg;
|
|
|
|
|
+ console.error("[importProducts] DB error:", pgErr, "\nFull:", msg.substring(0, 500));
|
|
|
|
|
+ throw new TRPCError({ code: "INTERNAL_SERVER_ERROR", message: `DB insert failed: ${pgErr}` });
|
|
|
|
|
+ }
|
|
|
}),
|
|
}),
|
|
|
}),
|
|
}),
|
|
|
|
|
|