mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 05:39:11 +03:00
Show the correct error on FE.
This commit is contained in:
1 parent
f1ce2cd2c6
commit
00fd080bc5
2 files changed
+9
-4
No files matched your search
@@ -68,7 +68,11 @@ export const MoveQueryModal = ({ visible, snippets = [], onClose }: MoveQueryMod
|
||||
const [selectedId, setSelectedId] = useState<string>()
|
||||
|
||||
const { mutateAsync: createFolder, isLoading: isCreatingFolder } =
|
||||
useSQLSnippetFolderCreateMutation()
|
||||
useSQLSnippetFolderCreateMutation({
|
||||
onError: (error) => {
|
||||
toast.error(`Failed to create new folder: ${error.message}`)
|
||||
},
|
||||
})
|
||||
const { mutateAsync: moveSnippetAsync, isLoading: isMovingSnippet } = useContentUpsertMutation({
|
||||
onError: (error) => {
|
||||
toast.error(`Failed to move query: ${error.message}`)
|
||||
@@ -179,7 +183,8 @@ export const MoveQueryModal = ({ visible, snippets = [], onClose }: MoveQueryMod
|
||||
|
||||
onClose()
|
||||
} catch (error: any) {
|
||||
toast.error(`Failed to create new folder: ${error.message}`)
|
||||
// error will be handled by the mutation's onError callback
|
||||
console.error('Error moving snippets:', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ const handlePut = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
await getSnippet(updates.id)
|
||||
const updatedSnippet = await updateSnippet(updates.id, updates)
|
||||
return res.status(200).json(updatedSnippet)
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
if (error instanceof Error && error.message.includes('not found')) {
|
||||
const body = req.body
|
||||
const { data, error } = SnippetSchema.safeParse(body)
|
||||
@@ -77,7 +77,7 @@ const handlePut = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
return res.status(500).json({ error: 'Failed to create snippet' })
|
||||
}
|
||||
}
|
||||
return res.status(500)
|
||||
return res.status(500).json({ message: error?.message ?? 'Failed to update snippet' })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user