[ui] better error msg on text

feat/vaults
Tomáš Mládek 2022-02-03 17:02:21 +01:00
parent 97198848c4
commit 7f87f05b1c
No known key found for this signature in database
GPG Key ID: ED21612889E75EC5
2 changed files with 7 additions and 2 deletions

View File

@ -244,7 +244,7 @@
{/if}
{:else}
<div class="error">
{JSON.stringify($error)}
{$error}
</div>
{/if}
</div>

View File

@ -15,7 +15,12 @@ export function useSWR<D = unknown, E = Error>(
if (response.ok) {
data.set(await response.json());
} else {
throw new Error(await response.json());
let errorText = `${response.status} ${response.statusText}`;
const responseText = await response.text();
if (responseText) {
errorText += ` - ${responseText}`;
}
throw new Error(errorText);
}
} catch (err) {
error.set(err);