Add custom errors with thiserror, log thread id
This commit is contained in:
@@ -34,16 +34,22 @@
|
||||
return day % 2 === 0 ? 1 : 2;
|
||||
}
|
||||
|
||||
interface AppError {
|
||||
kind: string;
|
||||
details: string;
|
||||
}
|
||||
|
||||
async function generate() {
|
||||
let config = rota.toDTO();
|
||||
console.log(config);
|
||||
|
||||
try {
|
||||
let schedule = await invoke<MonthlyScheduleDTO>("generate", { config });
|
||||
console.log("replyFromGenerate:", schedule);
|
||||
console.log(schedule);
|
||||
rota.solution = schedule;
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
const { kind, details } = error as AppError;
|
||||
console.error(`[${kind}] - ${details}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +59,8 @@
|
||||
try {
|
||||
await invoke("export", { schedule });
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
const { kind, details } = error as AppError;
|
||||
console.error(`[${kind}] - ${details}`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user