feat: error boundary
This commit is contained in:
parent
24e686dafa
commit
11666081f9
@ -26,9 +26,19 @@ const urlRef = computed(() => {
|
||||
return props.imageQuery
|
||||
})
|
||||
|
||||
const { onFetchResponse, onFetchError, isFetching, execute } = baseFetch(
|
||||
const { onFetchResponse, isFetching, execute } = baseFetch(
|
||||
urlRef,
|
||||
{ immediate: false },
|
||||
{ immediate: false, updateDataOnError: true, onFetchError: async ({ error, data, response }) => {
|
||||
// same as afterFetch
|
||||
imageResult.result = 'error'
|
||||
const rawErrorMsg = (await response?.json()).error.message as string ?? '未知错误'
|
||||
if (rawErrorMsg.includes('Improper input')) {
|
||||
imageResult.message = '数据异常,无法拟合. 请使用其他时间段再试'
|
||||
return { error, data }
|
||||
}
|
||||
imageResult.message = rawErrorMsg ?? '未知错误'
|
||||
return { error, data }
|
||||
} },
|
||||
)
|
||||
watch(isFetching, (fetching) => {
|
||||
if (fetching) {
|
||||
@ -51,11 +61,6 @@ onFetchResponse(async (resp) => {
|
||||
}
|
||||
})
|
||||
|
||||
onFetchError(async (error) => {
|
||||
imageResult.result = 'error'
|
||||
imageResult.message = error
|
||||
})
|
||||
|
||||
function download() {
|
||||
if (imageResult.result === 'success') {
|
||||
const a = document.createElement('a')
|
||||
|
||||
@ -33,7 +33,7 @@ const urll = computed(() => {
|
||||
query.set('path', selected.path)
|
||||
query.set('day', selected.day)
|
||||
query.set('height_no', selected.height_no.toString())
|
||||
query.set('lat_ranges', selected.lat_ranges)
|
||||
query.set('lat_range', selected.lat_ranges)
|
||||
return `/saber/render/gravity_wave/per_day/wave_fitting?${query}`
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user