forked from akanyan/STARTLINER
feat: very silly error handling
This commit is contained in:
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;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user