forked from akanyan/STARTLINER
feat: very silly error handling
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import Button from 'primevue/button';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { invoke } from '../invoke';
|
||||
import { Package } from '../types';
|
||||
import { pkgKey } from '../util';
|
||||
|
||||
|
@ -5,7 +5,7 @@ import InputNumber from 'primevue/inputnumber';
|
||||
import InputText from 'primevue/inputtext';
|
||||
import RadioButton from 'primevue/radiobutton';
|
||||
import Toggle from 'primevue/toggleswitch';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { invoke } from '../invoke';
|
||||
import { usePrfStore } from '../stores';
|
||||
|
||||
const prf = usePrfStore();
|
||||
|
@ -1,15 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { Ref, ref } from 'vue';
|
||||
import Button from 'primevue/button';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
import { invoke } from '../invoke';
|
||||
|
||||
type StartStatus = 'ready' | 'preparing' | 'running';
|
||||
const startStatus: Ref<StartStatus> = ref('ready');
|
||||
|
||||
const startline = async () => {
|
||||
startStatus.value = 'preparing';
|
||||
await invoke('startline');
|
||||
try {
|
||||
await invoke('startline');
|
||||
} catch (e) {
|
||||
startStatus.value = 'ready';
|
||||
}
|
||||
};
|
||||
|
||||
const kill = async () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import Button from 'primevue/button';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { invoke } from '../invoke';
|
||||
import { Package } from '../types';
|
||||
import { needsUpdate, pkgKey } from '../util';
|
||||
|
||||
@ -16,7 +16,6 @@ const install = async () => {
|
||||
try {
|
||||
await invoke('install_package', { key: pkgKey(props.pkg) });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
if (props.pkg !== undefined) {
|
||||
props.pkg.js.busy = false;
|
||||
}
|
||||
|
26
src/invoke.ts
Normal file
26
src/invoke.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import {
|
||||
InvokeArgs,
|
||||
InvokeOptions,
|
||||
invoke as real_invoke,
|
||||
} from '@tauri-apps/api/core';
|
||||
import { message } from '@tauri-apps/plugin-dialog';
|
||||
|
||||
export const invoke = async <T>(
|
||||
cmd: string,
|
||||
args?: InvokeArgs,
|
||||
options?: InvokeOptions
|
||||
): Promise<T> => {
|
||||
try {
|
||||
return await real_invoke(cmd, args, options);
|
||||
} catch (e: unknown) {
|
||||
if (typeof e === 'string') {
|
||||
await message(`${cmd}: ${e}`, {
|
||||
title: `Error`,
|
||||
kind: 'error',
|
||||
});
|
||||
} else {
|
||||
console.error(`Unresolved error: ${e}`);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
import { open } from '@tauri-apps/plugin-dialog';
|
||||
import { invoke } from './invoke';
|
||||
import { Game, Package, Profile, ProfileMeta } from './types';
|
||||
import { changePrimaryColor, pkgKey } from './util';
|
||||
|
||||
|
Reference in New Issue
Block a user