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

GLTF: Return the error file path when an import fails. #94751

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

radiantgurl
Copy link
Contributor

Allows the user to see which file failed to import and why, making it easier to spot import errors of .blend files.

@radiantgurl radiantgurl requested a review from a team as a code owner July 25, 2024 19:18
@fire fire changed the title GLTF: Return the actual error when an import fails. GLTF: Return the actual error file path when an import fails. Jul 25, 2024
@fire fire changed the title GLTF: Return the actual error file path when an import fails. GLTF: Return the error file path when an import fails. Jul 25, 2024
@@ -7416,7 +7416,7 @@ Error GLTFDocument::append_from_file(String p_path, Ref<GLTFState> p_state, uint

Error err;
Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::READ, &err);
ERR_FAIL_COND_V(err != OK, ERR_FILE_CANT_OPEN);
ERR_FAIL_COND_V_MSG(err != OK, err, vformat(R"(Can't open file at path "%s")", p_path));
Copy link
Member

Choose a reason for hiding this comment

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

This is changing the return value from ERR_FILE_CANT_OPEN to err. Did you check that FileAccess::open wouldn't return other error codes, and that call sites for append_from_file don't make assumptions on the returned error?

Copy link
Member

Choose a reason for hiding this comment

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

I think returning err is better, because it can provide more information. The file access functions usually return ERR_FILE_CANT_OPEN but can also return other values in other cases such as the function being called with invalid parameters.

As for the places that call append_from_file, the only internal usage just cares about err != OK, but this function is also exposed, so it technically changes behavior. However, I think it's a good change.

@AThousandShips AThousandShips added this to the 4.4 milestone Jul 26, 2024
@AThousandShips AThousandShips modified the milestones: 4.4, 4.x Jul 26, 2024
@aaronfranke
Copy link
Member

@RadiantUwU Can you rebase this pull request?

@radiantgurl
Copy link
Contributor Author

Finally out of burnout, sorry for the long wait.

Verified

This commit was created on github.com and signed with GitHub’s verified signature.
Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

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

I think this is a good change.

@fire fire requested a review from a team October 31, 2024 01:19
@radiantgurl radiantgurl requested a review from akien-mga November 5, 2024 17:27
@akien-mga akien-mga modified the milestones: 4.x, 4.4 Nov 11, 2024
@Repiteo Repiteo merged commit 3c15707 into godotengine:master Nov 11, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 11, 2024

Thanks!

@radiantgurl radiantgurl deleted the patch-2 branch November 12, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants