Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error handling when importing scene #421

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions packages/preload/src/modules/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,28 @@ export async function getProjects(paths: string | string[]): Promise<[Project[],
const missing: string[] = [];

for (const _path of paths) {
if (!(await exists(_path))) {
// _path doesn't exist
missing.push(_path);
} else if (await isDCL(_path)) {
// _path is a project
promises.push(getProject(_path));
} else {
// _path is a directory with projects
const files = await fs.readdir(_path);
for (const dir of files) {
try {
const projectDir = path.join(_path, dir);
if (await isDCL(projectDir)) {
promises.push(getProject(projectDir));
}
// eslint-disable-next-line no-empty
} catch (_) {}
try {
if (!(await exists(_path))) {
// _path doesn't exist
missing.push(_path);
} else if (await isDCL(_path)) {
// _path is a project
promises.push(getProject(_path));
} else {
// _path is a directory with projects
const files = await fs.readdir(_path);
for (const dir of files) {
try {
const projectDir = path.join(_path, dir);
if (await isDCL(projectDir)) {
promises.push(getProject(projectDir));
}
// eslint-disable-next-line no-empty
} catch (_) {}
}
}
} catch (_) {
missing.push(_path);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it going to enter here when the fs.readdir throws an error?

In that case, should we skip the path because it isn't accessible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was following the same approach as the code does when the path doesn't exist or its unaccessible.

      if (!(await exists(_path))) {
        // _path doesn't exist
        missing.push(_path);

}
}

Expand Down
Loading