Add Toast errors
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { type Writable, writable } from "svelte/store";
|
||||
import { main } from "$wails/models";
|
||||
import { GetFood } from "$wails/main/App";
|
||||
import { toast } from "svelte-sonner";
|
||||
|
||||
async function createStore(): Promise<Writable<main.Food[]>> {
|
||||
let foods: main.Food[] = [];
|
||||
let res: main.WailsFood = await GetFood();
|
||||
if (!res.success) {
|
||||
console.error("failed to get foods with error" + res.error);
|
||||
toast.error(`Failed to get foods with error: ${res.error}`);
|
||||
} else {
|
||||
foods = res.data;
|
||||
}
|
||||
@@ -20,7 +21,7 @@ async function createStore(): Promise<Writable<main.Food[]>> {
|
||||
refresh: async () => {
|
||||
const res = await GetFood();
|
||||
if (!res.success) {
|
||||
console.error("failed to get foods with error" + res.error);
|
||||
toast.error(`Failed to get foods with error: ${res.error}`);
|
||||
return;
|
||||
}
|
||||
set(res.data);
|
||||
|
Reference in New Issue
Block a user