Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit b75ba93

Browse files
committed
Selecting a bad project folder will show toast
1 parent 2a7da7b commit b75ba93

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src-tauri/src/project.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ pub struct SearchOptions {
4242
}
4343

4444
// load a project at a given path
45-
pub fn load(path: impl AsRef<Path>) -> anyhow::Result<Project> {
45+
pub fn load(path: impl AsRef<Path>) -> Result<Project, errors::AnyError> {
4646
let path = path.as_ref();
47+
let assets_path = path.join("Assets");
48+
49+
if !assets_path.exists() {
50+
return Err(errors::io_not_found("Invalid project path"));
51+
}
52+
4753
let file_name = path
4854
.file_name()
4955
.ok_or(errors::io_not_found("Invalid project path"))?;

src/views/projects/projects-header.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { TauriRouter } from "../../utils/tauri-router";
66
import { open } from "@tauri-apps/api/dialog";
77
import { UseState } from "../../utils";
88
import { ProjectViewData } from "./projects-view";
9+
import { routeErrorToToast } from "../../utils/toast-utils";
910

1011
export default function ProjectsHeader({
1112
projectData,
@@ -21,14 +22,18 @@ export default function ProjectsHeader({
2122
});
2223
if (!folder) return;
2324

24-
const project = await TauriRouter.add_project(folder as string);
25-
// console.log("project:", project);
25+
try {
26+
const project = await TauriRouter.add_project(folder as string);
27+
// console.log("project:", project);
2628

27-
const results = await TauriRouter.get_projects();
28-
// console.log("projects:", results);
29+
const results = await TauriRouter.get_projects();
30+
// console.log("projects:", results);
2931

30-
projectData.set((s) => ({ ...s, projects: results }));
31-
// dispatch({ type: "set_projects", projects: results });
32+
projectData.set((s) => ({ ...s, projects: results }));
33+
// dispatch({ type: "set_projects", projects: results });
34+
} catch (error) {
35+
routeErrorToToast(error);
36+
}
3237
}
3338

3439
async function startNewProject() {

0 commit comments

Comments
 (0)