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 { } else {
let tauri = await import("@tauri-apps/api/tauri"); let tauri = await import("@tauri-apps/api/tauri");
try {
if (path[0] === "client_info") { if (path[0] === "client_info") {
let from_rust = await tauri.invoke("client_info_rust",{}); let from_rust = await tauri.invoke("client_info_rust",{});
@ -166,6 +167,15 @@ const handler = {
} }
return res || {}; 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") { } else if (path[0] === "upload_chunk") {
let session_id = args[0]; let session_id = args[0];
let upload_id = args[1]; let upload_id = args[1];
@ -202,8 +212,11 @@ const handler = {
} else { } else {
let arg = {}; let arg = {};
args.map((el,ix) => arg[mapping[path[0]][ix]]=el) 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"> <div class="mt-4">
<CheckBadge color="green" size="3em" /> <CheckBadge color="green" size="3em" />
</div> </div>
<div class="mt-4"> <div class="mt-4 mb-4">
{@html $t("pages.wallet_info.scan_qr.scan_successful")} {@html $t("pages.wallet_info.scan_qr.scan_successful")}
</div> </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> </li>
{/if} {/if}
{/if} {/if}

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

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

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

Loading…
Cancel
Save