mirror of https://github.com/hykilpikonna/AquaDX
[F] Fix error display
parent
2b26304d92
commit
da648190db
|
@ -3,14 +3,13 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { fade } from 'svelte/transition'
|
import { fade } from 'svelte/transition'
|
||||||
import type { ConfirmProps } from "../libs/generalTypes";
|
import type { ConfirmProps } from "../libs/generalTypes";
|
||||||
import { DISCORD_INVITE } from "../libs/config";
|
|
||||||
import { t } from "../libs/i18n"
|
import { t } from "../libs/i18n"
|
||||||
import Loading from './ui/Loading.svelte';
|
import Loading from './ui/Loading.svelte';
|
||||||
import Error from './ui/Error.svelte';
|
import Error from './ui/Error.svelte';
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
export let confirm: ConfirmProps | null = null
|
export let confirm: ConfirmProps | null = null
|
||||||
export let error: string | null
|
export let error: string | null = null
|
||||||
export let loading: boolean = false
|
export let loading: boolean = false
|
||||||
|
|
||||||
function doConfirm(fn?: () => void) {
|
function doConfirm(fn?: () => void) {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
export let isSrc: boolean = true
|
export let isSrc: boolean = true
|
||||||
|
|
||||||
export let tested: boolean = false
|
export let tested: boolean = false
|
||||||
let [loading, error, expectedError] = [false, "", ""]
|
let [loading, error] = [false, ""]
|
||||||
|
|
||||||
function testConnection() {
|
function testConnection() {
|
||||||
if (loading) return
|
if (loading) return
|
||||||
|
@ -21,11 +21,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
|
error = ""
|
||||||
console.log("Testing connection...")
|
console.log("Testing connection...")
|
||||||
TRANSFER.check({...src, ...gameInfo}).then(res => {
|
return TRANSFER.check({...src, ...gameInfo}).then(res => {
|
||||||
console.log("Connection test result:", res)
|
console.log("Connection test result:", res)
|
||||||
tested = true
|
tested = true
|
||||||
}).catch(err => expectedError = err.message).finally(() => loading = false)
|
}).catch(err => error = err.message).finally(() => loading = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
let messages: string[] = []
|
let messages: string[] = []
|
||||||
|
@ -36,6 +37,7 @@
|
||||||
if (loading || !tested) return reject("Please test connection first")
|
if (loading || !tested) return reject("Please test connection first")
|
||||||
if (exportedData) return resolve(exportedData)
|
if (exportedData) return resolve(exportedData)
|
||||||
console.log("Exporting data...")
|
console.log("Exporting data...")
|
||||||
|
error = ""
|
||||||
|
|
||||||
TRANSFER.pull({...src, ...gameInfo}, (msg: TrStreamMessage) => {
|
TRANSFER.pull({...src, ...gameInfo}, (msg: TrStreamMessage) => {
|
||||||
console.log("Export progress: ", JSON.stringify(msg))
|
console.log("Export progress: ", JSON.stringify(msg))
|
||||||
|
@ -43,7 +45,7 @@
|
||||||
if ('message' in msg) messages = [...messages, msg.message]
|
if ('message' in msg) messages = [...messages, msg.message]
|
||||||
|
|
||||||
if ('error' in msg) {
|
if ('error' in msg) {
|
||||||
expectedError = msg.error
|
error = msg.error
|
||||||
reject(msg.error)
|
reject(msg.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +57,7 @@
|
||||||
exportedData = msg.data
|
exportedData = msg.data
|
||||||
resolve(msg.data)
|
resolve(msg.data)
|
||||||
}
|
}
|
||||||
}).catch(err => { expectedError = err; reject(err) })
|
}).catch(err => { error = err; reject(err) })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,21 +70,22 @@
|
||||||
if (loading || !tested) return
|
if (loading || !tested) return
|
||||||
console.log("Import data...")
|
console.log("Import data...")
|
||||||
loading = true
|
loading = true
|
||||||
|
error = ""
|
||||||
|
|
||||||
return TRANSFER.push({...src, ...gameInfo}, data).then(() => {
|
return TRANSFER.push({...src, ...gameInfo}, data).then(() => {
|
||||||
console.log("Data imported successfully")
|
console.log("Data imported successfully")
|
||||||
messages = ["Data imported successfully"]
|
messages = ["Data imported successfully"]
|
||||||
}).catch(err => expectedError = err.message).finally(() => loading = false)
|
}).catch(err => error = err.message).finally(() => loading = false)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<StatusOverlays {loading} {error} />
|
<StatusOverlays {loading} />
|
||||||
|
|
||||||
<div class="server source" class:src={isSrc} class:hasError={expectedError} class:tested={tested}>
|
<div class="server source" class:src={isSrc} class:hasError={error} class:tested={tested}>
|
||||||
<h3>{isSrc ? "Source" : "Target"} Server</h3>
|
<h3>{isSrc ? "Source" : "Target"} Server</h3>
|
||||||
|
|
||||||
{#if expectedError}
|
{#if error}
|
||||||
<blockquote class="error-msg">{expectedError}</blockquote>
|
<blockquote class="error-msg">{error}</blockquote>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<!-- First input line -->
|
<!-- First input line -->
|
||||||
|
|
Loading…
Reference in New Issue