Fix error handling in search

This commit is contained in:
2023-05-30 23:35:18 +02:00
parent 7ff314c8fe
commit b2a5d42cdb
3 changed files with 10 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ import { fs_path_url } from "./FilesystemUtil";
export let state
let downloads = 0
let bandwidth_used = 0
let transfer_used = 0
let socket = null
let error_msg = "Loading..."
@@ -37,7 +37,7 @@ const update_base = async base => {
error_msg = ""
downloads = j.downloads
bandwidth_used = j.bandwidth_free + j.bandwidth_paid
transfer_used = j.transfer_free + j.transfer_paid
}
socket.onerror = err => {
if (socket === null) {
@@ -74,8 +74,8 @@ onDestroy(close_socket)
{:else}
<div class="label">Downloads</div>
<div class="stat">{formatThousands(downloads)}</div>
<div class="label">Bandwidth used</div>
<div class="stat">{formatDataVolume(bandwidth_used, 3)}</div>
<div class="label">Transfer used</div>
<div class="stat">{formatDataVolume(transfer_used, 3)}</div>
{/if}
</div>

View File

@@ -35,6 +35,9 @@ export const navigate = async (path, push_history) => {
console.debug("Path", path, "was not found, trying to navigate to parent")
navigate(fs_split_path(path).parent, push_history)
}
} else if (err.message) {
console.error(err)
alert("Error: "+err.message)
} else {
console.error(err)
alert("Error: "+err)

View File

@@ -39,9 +39,9 @@ const search = async (limit = 10) => {
try {
search_results = await fs_search(state.base.path, search_term, limit)
} catch (err) {
try {
error = JSON.parse(err).value
} catch {
if (err.value) {
error = err.value
} else {
alert(err)
console.error(err)
}