Cleaned up most vanilla try catches
This commit is contained in:
@@ -22,16 +22,20 @@ const validSkeleton = computed(() => worldSkeleton.value.name)
|
||||
async function handleSubmit() {
|
||||
if (!user.value) return
|
||||
|
||||
try {
|
||||
isLoading.value = true
|
||||
await $fetch("/api/worlds/create", { method: "POST", body: { ...worldSkeleton.value } })
|
||||
isLoading.value = true
|
||||
|
||||
emit("on-close")
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
} finally {
|
||||
const { error } = await tryCatch(
|
||||
$fetch("/api/worlds/create", { method: "POST", body: { ...worldSkeleton.value } })
|
||||
)
|
||||
|
||||
if (error) {
|
||||
console.log(error.message)
|
||||
isLoading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
emit("on-close")
|
||||
isLoading.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,22 +30,24 @@ const validSkeleton = computed(() => worldSkeleton.value.name)
|
||||
async function handleSubmit() {
|
||||
if (!user.value || !worldSkeleton.value) return
|
||||
|
||||
try {
|
||||
isLoading.value = true
|
||||
await $fetch(`/api/worlds/${worldSkeleton.value.id}`, { method: "PATCH", body: { ...worldSkeleton.value } })
|
||||
isLoading.value = true
|
||||
|
||||
toast({
|
||||
title: t("entity.world.updatedToast.title", { world: worldSkeleton.value.name }),
|
||||
variant: "success",
|
||||
duration: ToastLifetime.SHORT
|
||||
})
|
||||
const { error } = await tryCatch(
|
||||
$fetch(`/api/worlds/${worldSkeleton.value.id}`, { method: "PATCH", body: { ...worldSkeleton.value } })
|
||||
)
|
||||
|
||||
emit("on-close")
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
if (error) {
|
||||
console.log(error.message)
|
||||
}
|
||||
|
||||
toast({
|
||||
title: t("entity.world.updatedToast.title", { world: worldSkeleton.value.name }),
|
||||
variant: "success",
|
||||
duration: ToastLifetime.SHORT
|
||||
})
|
||||
|
||||
emit("on-close")
|
||||
isLoading.value = false
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user