-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Error handling for FileAccess.get_file_as_*
#82595
Error handling for FileAccess.get_file_as_*
#82595
Conversation
02fbf74
to
aac7be9
Compare
As far as I can see,
What do you think? |
@RandomShaper That was my initial line of thought too (with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
I had missed this when reviewing, but I don't think that's correct with the current implementation. Ref<FileAccess> FileAccess::_open(const String &p_path, ModeFlags p_mode_flags) {
Error err = OK;
Ref<FileAccess> fa = open(p_path, p_mode_flags, &err);
last_file_open_error = err;
if (err) {
return Ref<FileAccess>();
}
return fa;
}
Ref<FileAccess> FileAccess::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key) {
Ref<FileAccess> fa = _open(p_path, p_mode_flags);
if (fa.is_null()) {
return fa;
}
Ref<FileAccessEncrypted> fae;
fae.instantiate();
Error err = fae->open_and_parse(fa, p_key, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ);
last_file_open_error = err;
if (err) {
return Ref<FileAccess>();
}
return fae;
}
The name might be a bit confusing, but it's the last It might be worth clarifying this in the documentation for FileAccess and DirAccess |
aac7be9
to
54ea062
Compare
The CI error is a GitHub Actions fluke. Rebasing on top of the just merged #83147 might help (though not 100% sure yet). |
- Assign last error in said `FileAccess.get_file_as_bytes` and `FileAccess.get_file_as_string` - Document error handling for said methods
54ea062
to
bf3f6e3
Compare
Thanks! |
What happens on errors in
FileAccess.get_file_as_bytes
andFileAccess.get_file_as_string
is currently undocumented. It's also impossible to retrieve the actual error that happened.FileAccess.get_file_as_bytes
andFileAccess.get_file_as_string