Skip to content

Commit f1b67c3

Browse files
authored
chore: generate-v4 expose error message (supabase#36702)
1 parent a6b88de commit f1b67c3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

apps/studio/pages/api/ai/sql/generate-v4.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,23 @@ async function handlePost(req: NextApiRequest, res: NextApiResponse) {
370370
tools,
371371
})
372372

373-
result.pipeDataStreamToResponse(res)
373+
result.pipeDataStreamToResponse(res, {
374+
getErrorMessage: (error) => {
375+
if (error == null) {
376+
return 'unknown error'
377+
}
378+
379+
if (typeof error === 'string') {
380+
return error
381+
}
382+
383+
if (error instanceof Error) {
384+
return error.message
385+
}
386+
387+
return JSON.stringify(error)
388+
},
389+
})
374390
} catch (error) {
375391
console.error('Error in handlePost:', error)
376392
if (error instanceof Error) {

0 commit comments

Comments
 (0)