feat: show toast on some errors

This commit is contained in:
2026-05-07 17:19:08 +02:00
parent f415edab57
commit 4aff3874d3
3 changed files with 19 additions and 8 deletions
+2
View File
@@ -1,5 +1,6 @@
import type { createKeyMap } from '$lib/helpers/createKeyMap';
import { panelState } from '$lib/sidebar/PanelState.svelte';
import { toast } from '@nodarium/ui';
import FileSaver from 'file-saver';
import type { GraphManager } from './graph-manager.svelte';
import type { GraphState } from './graph-state.svelte';
@@ -146,6 +147,7 @@ export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: Gr
type: 'application/json;charset=utf-8'
});
FileSaver.saveAs(blob, 'nodarium-graph.json');
toast('Graph downloaded', 'success', 1500);
}
});
@@ -1,5 +1,5 @@
<script lang="ts">
import { Button } from '@nodarium/ui';
import { Button, toast } from '@nodarium/ui';
import FileSaver from 'file-saver';
import type { Group } from 'three';
import type { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
@@ -29,11 +29,12 @@
exporter.parse(
scene,
(gltf) => {
// download .gltf file
download(gltf as ArrayBuffer, 'plant', 'text/plain', 'gltf');
toast('Exported as GLTF', 'success');
},
(err) => {
console.log(err);
const msg = err instanceof Error ? err.message : String(err);
toast(`GLTF export failed: ${msg}`, 'error');
}
);
}
@@ -46,9 +47,14 @@
objExporter = new m.OBJExporter();
return objExporter;
}));
try {
const result = exporter.parse(scene);
// download .obj file
download(result, 'plant', 'text/plain', 'obj');
toast('Exported as OBJ', 'success');
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
toast(`OBJ export failed: ${msg}`, 'error');
}
}
</script>
+5 -2
View File
@@ -29,7 +29,7 @@
import { tutorialConfig } from '$lib/tutorial/tutorial-config';
import { Planty } from '@nodarium/planty';
import type { Graph, NodeInstance } from '@nodarium/types';
import { Spinner } from '@nodarium/ui';
import { Spinner, Toast, toast } from '@nodarium/ui';
import { createPerformanceStore } from '@nodarium/utils';
import type { Group } from 'three';
@@ -135,7 +135,8 @@
}
viewerComponent?.update(graphResult);
} catch (error) {
console.log('errors', error);
const msg = error instanceof Error ? error.message : String(error);
toast(`Execution failed: ${msg}`, 'error');
} finally {
clearTimeout(timeout);
isExecuting = false;
@@ -384,6 +385,8 @@
</Grid.Row>
</div>
<Toast />
<style>
header {
background-color: var(--color-layer-1);