fix Tauri API error handling

pull/37/head
Niko PLP 4 months ago
parent aa3b1321bd
commit abfe68b4ac
  1. 15
      ng-app/src/api.ts
  2. 8
      ng-app/src/routes/WalletInfo.svelte
  3. 3
      ng-app/src/routes/WalletLogin.svelte
  4. 1
      ng-app/src/routes/WalletLoginTextCode.svelte
  5. 1
      ng-app/src/store.ts

@ -72,6 +72,7 @@ const handler = {
}
} else {
let tauri = await import("@tauri-apps/api/tauri");
try {
if (path[0] === "client_info") {
let from_rust = await tauri.invoke("client_info_rust",{});
@ -166,6 +167,15 @@ const handler = {
}
return res || {};
} else if (path[0] === "wallet_import_from_code") {
let arg = {};
args.map((el,ix) => arg[mapping[path[0]][ix]]=el);
let res = await tauri.invoke(path[0],arg);
if (res) {
res.V0.content.security_img = Uint8Array.from(res.V0.content.security_img);
}
return res || {};
} else if (path[0] === "upload_chunk") {
let session_id = args[0];
let upload_id = args[1];
@ -202,7 +212,10 @@ const handler = {
} else {
let arg = {};
args.map((el,ix) => arg[mapping[path[0]][ix]]=el)
return tauri.invoke(path[0],arg)
return await tauri.invoke(path[0],arg)
}
}catch (e) {
throw JSON.parse(e);
}
}
},

@ -476,9 +476,15 @@
<div class="mt-4">
<CheckBadge color="green" size="3em" />
</div>
<div class="mt-4">
<div class="mt-4 mb-4">
{@html $t("pages.wallet_info.scan_qr.scan_successful")}
</div>
<Button
on:click={to_main_menu}
class="w-full text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:ring-primary-100/50 rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55"
>
{$t("buttons.go_back")}
</Button>
</li>
{/if}
{/if}

@ -123,7 +123,7 @@
wallet_from_import.set(null);
});
async function gotError(event) {
importing = false;
//importing = false;
console.error(event.detail);
}
async function gotWallet(event) {
@ -189,6 +189,7 @@
} else {
wallet = $wallets[selected]?.wallet;
}
importing = false;
}
function handleWalletUpload(event) {
const files = event.target.files;

@ -85,7 +85,6 @@
{#if error}
<div class=" max-w-6xl lg:px-8 mx-auto px-4 text-red-800">
<ExclamationTriangle class="animate-bounce mt-10 h-16 w-16 mx-auto" />
<p class="max-w-xl md:mx-auto lg:max-w-2xl mb-5">
{@html $t("errors.error_occurred", {
values: { message: display_error(error) },

@ -46,7 +46,6 @@ init({
export const display_error = (error: string) => {
// Check, if error tranlsation does not exist
const parts = error.split(":");
let res = get(format)("errors." + parts[0]);
if (parts[1]) {
res += " " + get(format)("errors." + parts[1]);

Loading…
Cancel
Save