refactored more error code
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { api, target } from '../../urls.svelte.js';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { display } from '../../time.svelte';
|
||||
|
||||
@@ -11,7 +12,6 @@
|
||||
let bookmarks = $state(null);
|
||||
let companies = $state(null);
|
||||
let documents = $state(null);
|
||||
let error = $state(null);
|
||||
let fulltext = false;
|
||||
let key = $state(router.getQueryParam('key'));
|
||||
let input = $state(router.getQueryParam('key'));
|
||||
@@ -67,7 +67,7 @@
|
||||
const res = await resp.json();
|
||||
bookmarks = Object.keys(res).length ? res : null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
error(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
const json = await resp.json();
|
||||
companies = Object.keys(json).length ? json : null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
error(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
const json = await resp.json();
|
||||
documents = Object.keys(json).length ? json : null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
error(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
const json = await resp.json();
|
||||
notes = Object.keys(json).length ? json : null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
error(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
const res = await resp.json();
|
||||
projects = Object.keys(res).length ? res : null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
error(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
const res = await resp.json();
|
||||
tasks = Object.keys(res).length ? res : null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
error(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
const res = await resp.json();
|
||||
times = Object.keys(res).length ? res : null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
error(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@
|
||||
const res = await resp.json();
|
||||
pages = Object.keys(res).length ? res : null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
error(resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,9 +144,6 @@
|
||||
|
||||
<fieldset class="search">
|
||||
<legend>{t('search')}</legend>
|
||||
{#if error}
|
||||
<span class="error">{error}</span>
|
||||
{/if}
|
||||
<form onsubmit={setKey}>
|
||||
<label>
|
||||
{t('key')}
|
||||
|
||||
Reference in New Issue
Block a user