refactor: output errors on devtools (#928)

zio/stable
三咲智子 Kevin Deng 2023-01-12 13:39:22 +08:00 committed by GitHub
parent 50c54144e6
commit 4e0777d723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 34 additions and 16 deletions

View File

@ -19,7 +19,8 @@ async function toggleFollow() {
const newRel = await masto.v1.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id) const newRel = await masto.v1.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
Object.assign(relationship!, newRel) Object.assign(relationship!, newRel)
} }
catch { catch (err) {
console.error(err)
// TODO error handling // TODO error handling
relationship!.following = !relationship!.following relationship!.following = !relationship!.following
} }
@ -31,7 +32,8 @@ async function unblock() {
const newRel = await masto.v1.accounts.unblock(account.id) const newRel = await masto.v1.accounts.unblock(account.id)
Object.assign(relationship!, newRel) Object.assign(relationship!, newRel)
} }
catch { catch (err) {
console.error(err)
// TODO error handling // TODO error handling
relationship!.blocking = true relationship!.blocking = true
} }
@ -43,7 +45,8 @@ async function unmute() {
const newRel = await masto.v1.accounts.unmute(account.id) const newRel = await masto.v1.accounts.unmute(account.id)
Object.assign(relationship!, newRel) Object.assign(relationship!, newRel)
} }
catch { catch (err) {
console.error(err)
// TODO error handling // TODO error handling
relationship!.muting = true relationship!.muting = true
} }

View File

@ -49,7 +49,10 @@ const saveSettings = async () => {
try { try {
const subscription = await updateSubscription() const subscription = await updateSubscription()
}
catch (err) {
// todo: handle error // todo: handle error
console.error(err)
} }
finally { finally {
busy = false busy = false
@ -72,7 +75,8 @@ const doSubscribe = async () => {
showSubscribeError = true showSubscribeError = true
} }
} }
catch { catch (err) {
console.error(err)
subscribeError = t('settings.notifications.push_notifications.subscription_error.request_error') subscribeError = t('settings.notifications.push_notifications.subscription_error.request_error')
showSubscribeError = true showSubscribeError = true
} }
@ -91,6 +95,9 @@ const removeSubscription = async () => {
try { try {
await unsubscribe() await unsubscribe()
} }
catch (err) {
console.error(err)
}
finally { finally {
busy = false busy = false
animateRemoveSubscription = false animateRemoveSubscription = false

View File

@ -32,7 +32,9 @@ async function oauth() {
}, },
}) })
} }
catch { catch (err) {
console.error(err)
displayError = true displayError = true
error = true error = true
await nextTick() await nextTick()

View File

@ -57,6 +57,9 @@ export const usePublish = (options: {
return status return status
} }
catch (err) {
console.error(err)
}
finally { finally {
isSending = false isSending = false
} }

View File

@ -86,6 +86,8 @@ export function usePaginator<T, P, U = T>(
} }
} }
catch (e) { catch (e) {
console.error(e)
error.value = e error.value = e
state.value = 'error' state.value = 'error'
} }

View File

@ -140,7 +140,8 @@ async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: mastodon.
if (!users.value.some(u => u.server === user.server && u.token === user.token)) if (!users.value.some(u => u.server === user.server && u.token === user.token))
users.value.push(user as UserLogin) users.value.push(user as UserLogin)
} }
catch { catch (err) {
console.error(err)
await signout() await signout()
} }
} }
@ -206,7 +207,7 @@ export async function removePushNotificationData(user: UserLogin, fromSWPushMana
await subscription.unsubscribe() await subscription.unsubscribe()
} }
catch { catch {
// juts ignore // just ignore
} }
} }
} }
@ -216,12 +217,7 @@ export async function removePushNotifications(user: UserLogin) {
return return
// unsubscribe push notifications // unsubscribe push notifications
try { await useMasto().v1.webPushSubscriptions.remove().catch(() => Promise.resolve())
await useMasto().v1.webPushSubscriptions.remove()
}
catch {
// ignore
}
} }
export async function signout() { export async function signout() {

View File

@ -24,7 +24,8 @@ const reload = async () => {
await masto.loginTo(currentUser.value) await masto.loginTo(currentUser.value)
clearError({ redirect: currentUser.value ? '/home' : `/${currentServer.value}/public/local` }) clearError({ redirect: currentUser.value ? '/home' : `/${currentServer.value}/public/local` })
} }
catch { catch (err) {
console.error(err)
state.value = 'error' state.value = 'error'
} }
} }

View File

@ -62,7 +62,9 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
if (accounts[0]) if (accounts[0])
return getAccountRoute(accounts[0]) return getAccountRoute(accounts[0])
} }
catch {} catch (err) {
console.error(err)
}
return '/home' return '/home'
}) })

View File

@ -16,7 +16,9 @@ async function download(url: string, fileName: string) {
const image = await $fetch(url, { responseType: 'arrayBuffer' }) const image = await $fetch(url, { responseType: 'arrayBuffer' })
await fs.writeFile(fileName, Buffer.from(image)) await fs.writeFile(fileName, Buffer.from(image))
} }
catch {} catch (err) {
console.error(err)
}
} }
async function fetchAvatars() { async function fetchAvatars() {