Skip to content

Commit 6a15ed6

Browse files
committed
Show red toast notification when model run has error
1 parent 08b093c commit 6a15ed6

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

apps/class-solid/src/lib/runner.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ const asyncRunner = wrap<typeof runClass>(worker);
1111

1212
export async function runClassAsync(config: Config): Promise<ClassOutput> {
1313
try {
14-
const output = asyncRunner(config);
15-
return output;
14+
return await asyncRunner(config);
1615
} catch (error) {
1716
console.error({ config, error });
18-
// TODO use toast to give feedback to the user
17+
throw error;
1918
}
20-
throw new Error("Model run failed");
2119
}

apps/class-solid/src/lib/store.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
mergeConfigurations,
99
pruneConfig,
1010
} from "@classmodel/class/config_utils";
11+
import { showToast } from "~/components/ui/toast";
1112
import { decodeAppState } from "./encode";
1213
import { parseExperimentConfig } from "./experiment_config";
1314
import type { ExperimentConfig } from "./experiment_config";
@@ -38,9 +39,19 @@ export async function runExperiment(id: number) {
3839

3940
// Run reference
4041
const referenceConfig = unwrap(exp.config.reference);
41-
const newOutput = await runClassAsync(referenceConfig);
42-
43-
setExperiments(id, "output", "reference", newOutput);
42+
try {
43+
const newOutput = await runClassAsync(referenceConfig);
44+
setExperiments(id, "output", "reference", newOutput);
45+
} catch (error) {
46+
showToast({
47+
title: "Error running reference configuration",
48+
description: `${(error as Error).message}; Please correct configuration and try again.`,
49+
variant: "destructive",
50+
duration: Number.POSITIVE_INFINITY,
51+
});
52+
setExperiments(id, "output", "running", false);
53+
return;
54+
}
4455

4556
// Run permutations
4657
let permCounter = 0;
@@ -50,8 +61,19 @@ export async function runExperiment(id: number) {
5061
referenceConfig,
5162
permConfig,
5263
) as Config;
64+
try {
5365
const newOutput = await runClassAsync(combinedConfig);
5466
setExperiments(id, "output", "permutations", permCounter, newOutput);
67+
} catch (error) {
68+
showToast({
69+
title: `Error running permutation: ${permConfig.name}`,
70+
description: `${(error as Error).message}. Please correct configuration and try again.`,
71+
variant: "destructive",
72+
duration: Number.POSITIVE_INFINITY,
73+
});
74+
setExperiments(id, "output", "running", false);
75+
return;
76+
}
5577
permCounter++;
5678
}
5779

0 commit comments

Comments
 (0)