feat: very silly error handling

This commit is contained in:
2025-03-03 15:50:53 +01:00
parent 6410ca2721
commit 898caf1430
6 changed files with 36 additions and 7 deletions

26
src/invoke.ts Normal file
View 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;
}
};